Quote:
|
Originally Posted by Yadrif
Is there an easier way to do this?
|
No, I would do it exactly like this.
Maybe just write it a bit more condensed as follows:
Code:
CREATE TRIGGER INS_TABLEA
AFTER INSERT ON TABLEA
REFERENCING NEW AS N
FOR EACH ROW MODE DB2SQL
INSERT INTO HISTORY_TBL (DATE_CHANGED, OPERATION, INS_DEL_VALUES_LIST)
VALUES (CURRENT TIMESTAMP, 'INSERT', 'COL1='||N.COL1||',COL2='||N.COL2)
#
The "current timestamp" could further be avoided by having a "WITH DEFAULT" on the "DATE_CHANGED" column ("ALTER TABLE history_tbl ALTER COLUMN date_changed SET DEFAULT"):
Code:
INSERT INTO HISTORY_TBL (OPERATION, INS_DEL_VALUES_LIST)
VALUES ('INSERT', 'COL1='||N.COL1||',COL2='||N.COL2)