Re: PostgreSQL sequence within function

From: Clark Allan <clarka(at)gmail(dot)com>
To: Tony Caduto <tony_caduto(at)amsoftwaredesign(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: PostgreSQL sequence within function
Date: 2005-07-05 18:27:53
Message-ID: 4a7a732105070511273949ac03@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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(at)amsoftwaredesign(dot)com> 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
> >
> >
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tony Caduto 2005-07-05 18:55:06 Re: PostgreSQL sequence within function
Previous Message D A GERM 2005-07-05 18:04:47 double entries into database when using IE