If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > update table into trigger but on same table trigger based

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-20-09, 03:20
rd4004 rd4004 is offline
Registered User
 
Join Date: May 2009
Posts: 11
Exclamation update table into trigger but on same table trigger based

Hello !

Here is my pbl ; I have a trigger on a table TAB1. The trigger fires After update in order to be able to execute an update command. This update have to update others records on the same table TAB1.

Is that possible ? and do the trigger fires again for the other updated records and again and again ??

thanks for your answer

Last edited by rd4004; 05-20-09 at 03:23. Reason: update the title
Reply With Quote
  #2 (permalink)  
Old 05-20-09, 07:39
Stealth_DBA Stealth_DBA is offline
Registered User
 
Join Date: May 2009
Posts: 472
rd4004, you should be able to do what you want without getting into an endless set of triggers firing.

When you create an UPDATE trigger you can specify OF COLUMN col-name(s).

For example:

Trigger1 AFTER UPDATE OF COLUMN col1 (action update col2)
Trigger2 AFTER UPDATE OF COLUMN col2 (action update col3)
Trigger3 AFTER UPDATE OF COLUMN col3 (action update col4)

Update table-name SET col1 = value WHERE ...

This will fire Trigger1 which updates col2
This will fire Trigger2 which updates col3
This will fire Trigger3 which updates col4

And you are done.

PS If Trigger3 updated col1 or col2 then you would have a problem.
Reply With Quote
  #3 (permalink)  
Old 05-21-09, 16:09
dav1mo dav1mo is offline
Registered User
 
Join Date: Dec 2007
Location: Richmond, VA
Posts: 782
you can put when condition on when to fire the trigger, such as columnX <> ??? or columna = ???
Dave
Reply With Quote
  #4 (permalink)  
Old 05-21-12, 10:01
felipelrz felipelrz is offline
Registered User
 
Join Date: May 2012
Posts: 1
Stealth_DBA u r the mann... I'm facing this problem all weekend on...
10x man
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On