Hi all,
I am currently working in a scenario where, I had to write trigger(insert, update and delete) for a certain table in DB2 database(DB2 for i V5R4).
The table have no primary key, but I need one to identify the records.
The application is legacy and hence I cannot expect the client to change the DB structure.
Hence I tried to use RRN( Relative Record Number) in my trigger.
Here is the trigger I wrote.
I read that RRN is stored in static section of trigger buffer, but I couldn't figure out how to use it.
I need some serious help.
Regards.
I am currently working in a scenario where, I had to write trigger(insert, update and delete) for a certain table in DB2 database(DB2 for i V5R4).
The table have no primary key, but I need one to identify the records.
The application is legacy and hence I cannot expect the client to change the DB structure.
Hence I tried to use RRN( Relative Record Number) in my trigger.
Here is the trigger I wrote.
Code:
CREATE TRIGGER "CMB"."CASPR_I" AFTER INSERT ON "CMB"."CASPR" REFERENCING NEW AS NEW_ROW FOR EACH ROW MODE DB2SQL BEGIN ATOMIC DECLARE RID DECIMAL(15,0); SET RID=NEW_ROW.RRN("CMB"."CASPR"); INSERT INTO "CMB"."AS400_CASPR" (ROW_ID,PREFIX,GEN_ACTION,GEN_DATE) VALUES(RID,NEW_ROW.PREFIX,'INSERT',CURRENT DATE); END
I need some serious help.
Regards.
Comment