tags:

views:

125

answers:

1

I have to create the trigger(s) which will keep the audit of my table. The trigger is supposed to execute on both insert and update.

currently i am having two triggers

One for 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 for 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 point is, if it possible to create a single trigger, in DB2, for doing the task? [ provided both, trigger are doing the same thing .]

+1  A: 

Sorry, DB2 doesn't offer a way to combine update and insert triggers together.

Fred Sobotka