Using Triggers in DB2 v8



IBM's flagship relational database management system

Using Triggers in DB2 v8

Postby mjspiz » Mon Jul 26, 2010 8:21 pm

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
:?:
mjspiz
 
Posts: 1
Joined: Mon Jul 26, 2010 8:16 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Using Triggers in DB2 v8

 

Re: Using Triggers in DB2 v8

Postby dick scherrer » Mon Jul 26, 2010 11:23 pm

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.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 92 times


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post