Subject | Re: Getting id of last inserted record |
---|---|
Author | hay77772000 |
Post date | 2003-04-28T20:31:45Z |
Hi. Thanks for speedy reply...
CREATE TRIGGER ACCOUNTS_BI FOR ACCOUNTS
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF (NEW.ID IS NULL) THEN
NEW.ID = GEN_ID(GEN_ACCOUNTS_ID, 1);
END ^
commit ^
SET TERM ; ^
but how does this help?!
Sorry for the slowness on my part!
Cheers,
David
> To have a reliable access to the id of last inserted record youhave no
> other option but to get the generator value on the client side.(but
>
> Depending on the tools you use there are different ways to do it
> you can always do it the way you did above).I thought this wasn't reliable though...?
> To keep your db operatable outside the client-app you can supply avalue
> in a before insert trigger by checking for NULL on the id fieldMy current trigger is as follows:
> (like: IF ( NEW.ID IS NULL ) THEN NEW.ID = GEN_ID ....)
CREATE TRIGGER ACCOUNTS_BI FOR ACCOUNTS
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF (NEW.ID IS NULL) THEN
NEW.ID = GEN_ID(GEN_ACCOUNTS_ID, 1);
END ^
commit ^
SET TERM ; ^
but how does this help?!
Sorry for the slowness on my part!
Cheers,
David