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 > Recursice Trigger

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-16-04, 01:34
ksolomon ksolomon is offline
Registered User
 
Join Date: Jun 2004
Posts: 38
Talking Recursice Trigger

Is there a way to stop the level of Triggering in the case of Recursive Triggers in DB2 v8.1 ?

Eg : Table1 has an after update Trigger Trig1, which updates table Table2 which inturn has an after update Trigget Trig2 which updates Table1. So this process continues to proceed till 16th level.

Now if I want to stop this recursive triggering after 1 level how I've to implement this ?
Reply With Quote
  #2 (permalink)  
Old 06-16-04, 09:59
J Petruk J Petruk is offline
Registered User
 
Join Date: Mar 2004
Location: Toronto, ON, Canada
Posts: 513
Quote:
Originally Posted by ksolomon
Is there a way to stop the level of Triggering in the case of Recursive Triggers in DB2 v8.1 ?

Eg : Table1 has an after update Trigger Trig1, which updates table Table2 which inturn has an after update Trigget Trig2 which updates Table1. So this process continues to proceed till 16th level.

Now if I want to stop this recursive triggering after 1 level how I've to implement this ?
You can specify NO CASCADE BEFORE in the definition to specify that the actions the trigger takes won't cause other triggers to fire.
__________________
--
Jonathan Petruk
DB2 Database Consultant
Reply With Quote
  #3 (permalink)  
Old 06-16-04, 10:20
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
But theirs are the AFTER triggers...

Control of recursion can be implemented at the "application" level: say, TRIG2 updates TABLE1 with some specific value (that would never come from another source of updates); TRIG1 checks that value and, if present, doesn't update TABLE2.
Reply With Quote
  #4 (permalink)  
Old 08-13-04, 15:29
urquel urquel is offline
Registered User
 
Join Date: Aug 2004
Posts: 330
add a when clause to break the cascading....
WHEN NEW.COLUMN1 <> OLD.COLUMN1
BEGIN ATOMIC.....

this will only cause the triggered action when the update is changing the value. (you may have to modify the when clause based upon your circumstances)
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