Page 1 of 1

Using Triggers in DB2 v8

PostPosted: Mon Jul 26, 2010 8:21 pm
by mjspiz
Hi all,

Can anyone help me to define a new Insert,Update & Delete trigger?
For example:

TBL-A is the main table. 200 columns and 800,000 rows.
TBL-B is a copy of the A table.

Anytime a row is Inserted, Updated or Deleted from TBL-A, I would like it occur on TBL-B also.

I have been reading on this, but cannot seem to find a good example.

Thank you.

Mike
:?:

Re: Using Triggers in DB2 v8

PostPosted: Mon Jul 26, 2010 11:23 pm
by dick scherrer
Hello,

Look here:
http://publibz.boulder.ibm.com/cgi-bin/ ... sqj10/5.74

From that same manual is this example:
        CREATE TRIGGER NEW_HIRE
           AFTER INSERT ON EMPLOYEE
           FOR EACH ROW MODE DB2SQL
           BEGIN ATOMIC
             UPDATE COMPANY_STATS SET NBEMP = NBEMP + 1;
           END
Modify the code after the "after insert" to do what you want.