Search Postgresql Archives

Re: PostgreSQL sequence within function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks for the help Tony,
But im still having some trouble.
 
Here is the exact function
-------------------------------------------
CREATE OR REPLACE FUNCTION sp_slide_create(int4, bool, bool, bool, varchar, text, varchar, varchar, int4)
RETURNS int4 AS'
DECLARE
 aScriptID ALIAS FOR $1;
 aAllowDGP ALIAS FOR $2;
 aAllowDGO ALIAS FOR $3;
 aWaitForSlideFinish ALIAS FOR $4;
 aTitle ALIAS FOR $5;
 aText ALIAS FOR $6;
 aFlashFileDGP ALIAS FOR $7;
 aFlashFileDGO ALIAS FOR $8;
 aSlideType ALIAS FOR $9;
 
 seqID int4 := nextval("seqslideid");
 
BEGIN
 INSERT INTO tblslides
 (slideid, scriptID, allowdgp, allowdgo, waitforslidefinish, title, text, flashfiledgp, flashfiledgo, slidetype)
 VALUES
 (seqID, aScriptID, aAllowDGP, aAllowDGO, aWaitForSlideFinish, aTitle, aText, aFlashFileDGP, aFlashFileDGO, aSlideType);

 RETURN seqID;
END;'

LANGUAGE 'plpgsql' VOLATILE;
-------------------------------------------
 
I can get the code above to fire no problem.  However, when i run the following i get an error.
 
------------------------------------------
select sp_slide_create(88, true, true, true, 'varcharOne', 'textOne', 'varcharTwo', 'varcharThree', 2);
 
ERROR:  column "seqslideid" does not exist
CONTEXT:  PL/pgSQL function "sp_slide_create" line 14 at block variables initialization
------------------------------------------
 
Thanks for the help
 
On 6/30/05, Tony Caduto <tony_caduto@xxxxxxxxxxxxxxxxxxxx> wrote:
All you where really mising was a semi colon afer nextval('myseq') and
the begin end.

CREATE or REPLACE FUNCTION getSeq()
RETURNS int AS
$$
begin
RETURN nextval('myseq');
end;
$$
LANGUAGE 'plpgsql';

Clark Allan wrote:

>----------------------------------------------
>CREATE FUNCTION getSeq()
>RETURNS int AS'
>RETURN nextval('myseq')
>'LANGUAGE 'plpgsql';
>----------------------------------------------
>
>Thanks for the help
>Clark
>
>



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux