Subject | Re: [ib-support] Getting id of last inserted record |
---|---|
Author | Lucas Franzen |
Post date | 2003-04-28T20:25:06Z |
David,
other option but to get the generator value on the client side.
Depending on the tools you use there are different ways to do it (but
you can always do it the way you did above).
To keep your db operatable outside the client-app you can supply a value
in a before insert trigger by checking for NULL on the id field
(like: IF ( NEW.ID IS NULL ) THEN NEW.ID = GEN_ID ....)
Luc.
> Hi. Am still continuing to port our system from mySQL to Firebird.To have a reliable access to the id of last inserted record you have no
>
> Have set up the database correctly, along with generators and
> triggers that simulate an autoincrement field.
>
> However, I still need a way to get the id back of the record just
> inserted, in a distributed, multiple-user environment.
>
> Can anyone let me know how to do so, please? I understand I could
> use SELECT GEN_ID(GEN_ATABLE, 0) FROM RDB$DATABASE; but that this
> cannot be relied on with other transactions etc..
other option but to get the generator value on the client side.
Depending on the tools you use there are different ways to do it (but
you can always do it the way you did above).
To keep your db operatable outside the client-app you can supply a value
in a before insert trigger by checking for NULL on the id field
(like: IF ( NEW.ID IS NULL ) THEN NEW.ID = GEN_ID ....)
Luc.