Subject | Re: Immediately get auto generated key |
---|---|
Author | zifnabbe <zifnabbe@users.sourceforge.net> |
Post date | 2003-02-09T14:12:30Z |
Thanks for your reply,
But I want to return the ID as output from stored procedure so that I
can use it further in my program. How can I put the ID as output? Is
the following correct?
DECLARE VARIABLE ID INTEGER;
BEGIN
ID = GEN_ID("GEN_SESSION_ID",1);
INSERT INTO
PLANSESSIONS (SESSION_ID, SESSION_INFO )
VALUES (:ID, :SESSIONINFO);
INTO :SESSIONID
SUSPEND;
END
Thanks,
Tom.
--- In ib-support@yahoogroups.com, "Arno Brinkman" <firebird@a...>
wrote:
But I want to return the ID as output from stored procedure so that I
can use it further in my program. How can I put the ID as output? Is
the following correct?
DECLARE VARIABLE ID INTEGER;
BEGIN
ID = GEN_ID("GEN_SESSION_ID",1);
INSERT INTO
PLANSESSIONS (SESSION_ID, SESSION_INFO )
VALUES (:ID, :SESSIONINFO);
INTO :SESSIONID
SUSPEND;
END
Thanks,
Tom.
--- In ib-support@yahoogroups.com, "Arno Brinkman" <firebird@a...>
wrote:
> Hi,key
>
> > Is it possible in one Stored Procedure to get the auto generated
> > for a row?IS NULL.
>
> I guess you use an generator in the trigger and check if SESSION_ID
>your
> > begin
> > INSERT INTO PLANSESSIONS ( SESSION_INFO )
> > VALUES ( :SESSIONINFO );
> > suspend;
> > end
> >
> > But would like to get directly the autogenerated key 'SESSION_ID'.
> > How can I do this?
>
> Generate first the ID in the SP and use that as input value inside
> INSERT.
>
> DECLARE VARIABLE ID INTEGER;
> BEGIN
> ID = GEN_ID("GEN_SESSION_ID",1);
> INSERT INTO
> PLANSESSIONS (SESSION_ID, SESSION_INFO )
> VALUES (:ID, :SESSIONINFO);
> SUSPEND;
> END
>
> Regards,
> Arno