Subject RE: [firebird-support] Re: Slq Server @@IDENTITY equivalent in FB
Author Alan McDonald
> > Hi Everyone,
> >
> > I'm still on the process of porting SQL Server DB to
> > Firebird.
> >
> > Does anyone knows of a SQL Server @@IDENTITY
> > equivalent in Firebird.
> >
> > Basically I have:
> >
> > Active BEFORE INSERT trigger for AS_USERS at position
> > 0
> > AS BEGIN
> > IF (NEW.USER_ID IS NULL) THEN
> > NEW.USER_ID = GEN_ID(AS_USERS_SEQ, 1);
> > END
> >
> > After I do my INSERT, I need to know the value of
> > USER_ID to return back to the caller program.
> >
>
>
> CURRENT_USER
>
> other useful ones.
>
> CURRENT_ROLE
> CURRENT_CONNECTION
> CURRENT_TRANSACTION
>
> > I'm using Fb 1.5(if that helps)
>
> You need 1.5 for the context variables.
>
> Although looking at your code, do you mean rather that you want to
> return a field value from an insert statement? I think that is a
> Firebird 2 feature. For FB 1.5, now you will need to use a stored
> procedure to achieve the same thing.
>
> Adam

better read that one again Adam, he needs a gen_id not CURRENT_USER
Alan