Subject Re: Immediately get auto generated key
Author zifnabbe <zifnabbe@users.sourceforge.net>
Many Thanks!

--- In ib-support@yahoogroups.com, "Arno Brinkman" <firebird@a...>
wrote:
> Hi,
>
> > 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
>
> Use it like this :
>
> CREATE PROCEDURE SP_INSERT_SESSION (SESSIONINFO VarChar(30)) returns
> (SESSION_ID Integer) AS
> DECLARE VARIABLE ID INTEGER;
> BEGIN
> ID = GEN_ID("GEN_SESSION_ID",1);
> INSERT INTO
> PLANSESSIONS (SESSION_ID, SESSION_INFO )
> VALUES (:ID, :SESSIONINFO);
> SESSION_ID = ID;
> SUSPEND;
> END
>
> Regards,
> Arno