This is a discussion on Delay a trigger within the DB2 forums, part of the Database Server Software category; --> Is there anyway to delay a trigger from firing for a few seconds? I have an after insert trigger ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Is there anyway to delay a trigger from firing for a few seconds? I have an after insert trigger on table1, which selects information from table2 and table3. Obviously it cannot fire unless the required rows in table2 and 3 are filled out first. I can't just put the trigger on table2 or 3, because the order of insert there is different, depending on how the applicaiton is used, plus it would make for a very complicated trigger goig that way. Basically in the application, the user picks something, in the database in either does insert tab1, insert tab2, insert tab3, or if he does something else, insert tab1, insert tab3 insert tab2. So the intent is to just delay an after trigger on tab1 from firing for a few seconds to allow tab2 and 3 to get filled out. I don't think it's possible,any suggestions? Timing isn't critical for what the trigger does, it is critical not to hang the application though. Thanks Ken |
| |||
| Not sure how to delay the trigger, but you could dely your trigger logic after it fired by iterating through a whileloop doing time calculations compares. Then run your other logic after the loop finishes. This is an old way of programming time delays HTH Chris |
| |||
| Chris wrote: > Not sure how to delay the trigger, but you could dely your trigger > logic after it fired by iterating through a whileloop doing time > calculations compares. Then run your other logic after the loop > finishes. This is an old way of programming time delays > > HTH > > Chris > The problem with that is it hangs the real insert on tab1 to wait for it to finish, any time looping for the trigger on tab1, essentially hangs the insert on tab1, and hence the application waiting for that insert to finish. I used 2 triggers like the other person said, with conditional clauses. The problem I have, is the next trigger I need to make involves selecting data from 12 tables, not 2, and the order is different depending on what buttons in the app are being picked. I really don't want to create 12 triggers with conditional clauses. Still looking for additional suggestions, thanks for the replies so far! Ken |
| |||
| yoyo wrote: > Larry wrote: > >> I suggest doing this logic in the application language, not using a >> trigger. >> > No access to it. Closed source. Use an intermendiate table which is timestamped. Then do the real work with another connection. Basically you woudl be using a queue. Cheers Serge -- Serge Rielau DB2 SQL Compiler Development IBM Toronto Lab |