Trigger Example - Mainframe DB2 Trigger.



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)


This site provides a list of interesting subjects, tips, and tricks. Although it is mostly computer tips, there are also tips and tricks related to various other helpful topics besides just computers. If you have an important tip that you think should be listed, feel free to post it below. Although I still take tips via email, I often scan and review posts on the page below and prefer that method.

Submit Tip or Ask Question:

Post It Here

View Other Databases:

View All Tips and Tricks
Spyware and System Task Database