Subject | How to return generated value in TRIGGER ? |
---|---|
Author | Ionut Ichim |
Post date | 2007-06-18T08:55:11Z |
Hi all !
I have a trigger on a table :
CREATE TRIGGER TRIG_GS_PR_BI FOR GS_PR
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF ((NEW.ID IS NULL) OR (NEW.ID =0)) THEN
NEW.ID =NEXT VALUE FOR GEN_GS_PR_ID;
END
In my application I use a stored procedure to insert data,for ID I send 0 as the trigger to use generator.My problem is how to get the value written in ID, I need it in my app after I call INSERT.Is there a simple way or a have to query table for max(ID).
Thanks !
---------------------------------
Need a vacation? Get great deals to amazing places on Yahoo! Travel.
[Non-text portions of this message have been removed]
I have a trigger on a table :
CREATE TRIGGER TRIG_GS_PR_BI FOR GS_PR
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF ((NEW.ID IS NULL) OR (NEW.ID =0)) THEN
NEW.ID =NEXT VALUE FOR GEN_GS_PR_ID;
END
In my application I use a stored procedure to insert data,for ID I send 0 as the trigger to use generator.My problem is how to get the value written in ID, I need it in my app after I call INSERT.Is there a simple way or a have to query table for max(ID).
Thanks !
---------------------------------
Need a vacation? Get great deals to amazing places on Yahoo! Travel.
[Non-text portions of this message have been removed]