Unix Technical Forum

Delay a trigger

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


Go Back   Unix Technical Forum > Database Server Software > DB2

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 04:41 AM
yoyo
 
Posts: n/a
Default Delay a trigger

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 04:41 AM
Brian Tkatch
 
Posts: n/a
Default Re: Delay a trigger

>I can't just put the trigger on table2 or 3, because the order of insert there is different

Make two TRIGGERs, one for 2 and another for 3, just check for the
record in the other TABLE in order to do anything.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-27-2008, 04:41 AM
Chris
 
Posts: n/a
Default Re: Delay a trigger

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-27-2008, 04:41 AM
yoyo
 
Posts: n/a
Default Re: Delay a trigger

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-27-2008, 04:41 AM
Larry
 
Posts: n/a
Default Re: Delay a trigger

I suggest doing this logic in the application language, not using a
trigger.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-27-2008, 04:41 AM
yoyo
 
Posts: n/a
Default Re: Delay a trigger

Larry wrote:
> I suggest doing this logic in the application language, not using a
> trigger.
>

No access to it. Closed source.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-27-2008, 04:41 AM
Serge Rielau
 
Posts: n/a
Default Re: Delay a trigger

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 02-27-2008, 04:41 AM
Brian Tkatch
 
Posts: n/a
Default Re: Delay a trigger

If a TRIGGER can CALL another PROCEDURE, have a PROCEDURE do all the
logic. Add a TRIGGER to each of the twelve TABLEs to CALL the PROCEDURE
with it's own name

B.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:18 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com