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 > Procedure and triggers

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-05-11, 13:41
kbum kbum is offline
Registered User
 
Join Date: Mar 2011
Posts: 12
Lightbulb Procedure and triggers

Hey, i have a big problem. I have 2 tables and each one have 1 trigger.
Example:
Table1 have a trigger AFTER SAVE. This trigger call a procedure that make a INSERT on Table2.
The Table2 have a trigger AFTER SAVE. This trigger call a procedure that make a INSERT on Table1.
I need this structure because we are remodeling the existing bank and I can not disable the current tables. However, this structure generates a LOOP.
I thought of passing a parameter indicating the origin of the call, but could not make the TRIGGER recognize the parameter reported. Does anyone have any suggestions for solving this problem? Recalling that the tables are in the same database.
Reply With Quote
  #2 (permalink)  
Old 04-05-11, 13:49
dav1mo dav1mo is offline
Registered User
 
Join Date: Dec 2007
Location: Richmond, VA
Posts: 782
add a column to the tables in question, call it triggered or something along those lines with default of 'N'. Have trigger process insert a value of 'Y', then add WHEN condition of WHEN triggered = 'N' then perform insert else null.
Dave
Reply With Quote
  #3 (permalink)  
Old 04-05-11, 13:51
kbum kbum is offline
Registered User
 
Join Date: Mar 2011
Posts: 12
Lightbulb

So. I even thought about this solution, only that the database has over 3000 tables. My attempt was to find another solution.
Reply With Quote
  #4 (permalink)  
Old 04-11-11, 07:26
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Unless you can tolerate some delay, you could use replication.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Tags
db2, loop, procedure, stored procedures, trigger

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