Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2004
    Posts
    38

    Talking Unanswered: 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 ?

  2. #2
    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

  3. #3
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    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.

  4. #4
    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)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •