Topic
  • 1 reply
  • Latest Post - ‏2012-03-17T06:51:27Z by SystemAdmin
redridingfraggle
redridingfraggle
1 Post

Pinned topic Need help with DB2 trigger

‏2012-03-16T10:42:27Z |
Hi,

Could anyone please tell me how to do an inner join from the table that is the subject of a trigger.

The Sybase equivalent is:

CREATE TRIGGER upd_table on TRIGGERTABLE
FOR UPDATE AS BEGIN

update UPDATEDTABLE
set column1 = new.column1
, column2 = leftjointable.column2
where inserted new
, LEFTJOINTABLE leftjointable
, UPDATEDTABLE updatedtable
where new.id = updatedtable.id
and new.id *= leftjointable.id

END
go.

However, since there is no concept of inserted in DB2, the trigger has only a "left outer join LEFTJOINTABLE" with no from clause and does not compile.

So how would the above statement translate into an AFTER UPDATE trigger in DB2?

Many thanks
  • SystemAdmin
    SystemAdmin
    17917 Posts

    Re: Need help with DB2 trigger

    ‏2012-03-17T06:51:27Z  
    I think that your question was answered in
    http://www.dbforums.com/db2/1676902-need-help-db2-trigger.html

    Please try a sample code in #2 by n_i.
    n_i also answered your additional questions in #4 and #6.