I need to create a trigger (s) that will store an audit of my table. It is assumed that the trigger will be executed for both insert and update.
I currently have two triggers
One to insert :
CREATE TRIGGER SCH.TRG_TBL1_AFT_I AFTER INSERT ON SCH.TBL1 REFERENCING NEW AS n FOR EACH ROW MODE DB2SQL INSERT INTO SCH.TBL1_AUDIT VALUES( .. ,, .. );
Another to update
CREATE TRIGGER SCH.TRG_TBL1_AFT_U AFTER UPDATE ON SCH.TBL1 REFERENCING NEW AS n FOR EACH ROW MODE DB2SQL INSERT INTO SCH.TBL1_AUDIT VALUES( .. ,, .. );
But the fact is, is it possible to create a single trigger in DB2 to complete a task? [provided that both triggers do the same thing.]
Rakesh juyal
source share