Free Tips, Tutorials, and Examples | |
|
Main Page Submit Question or Tip
View List Detailed Description:
DB2 Trigger Example: Many people use triggers in their mainframe code for
various different reasons, and it is a very handy feature of DB2. If creating a trigger named trigger1, and everytime columns DB2_LOC or DB2_PRICE are updated in the DB2 table named TABLE1, a duplicate history row is also created in DB2 table named TABLE2. This trigger below will guarantee the exact history is always kept for this condition. CREATE TRIGGER TRIGGER1 AFTER UPDATE OF DB2_LOC, DB2_PRICE ON TABLE1 REFERENCING OLD AS OLD_TAB NEW AS NEW_TAB FOR EACH ROW MODE DB2SQL INSERT INTO TABLE2 (DB2_LOC, DB2_PRICE, DB2_CITY) VALUES(OLD_TAB.DB2_LOC,OLD_TAB.DB2_PRICE,OLD_TAB.DB2_CITY) FOR EACH ROW MODE DB2SQL INSERT INTO TABLE2 (DB2_LOC, DB2_PRICE, DB2_CITY) VALUES(OLD_TAB.DB2_LOC,OLD_TAB.DB2_PRICE,OLD_TAB.DB2_CITY) VALUES(OLD_TAB.DB2_LOC,OLD_TAB.DB2_PRICE,OLD_TAB.DB2_CITY)
Submit Tip or Ask Question:
View Other Databases: | |