Subject Re: DELAY OR WAIT
Author Adam
>
> In his case, he should simply use triggers, which get fired when a
new entry is inserted/updated etc.. An SP could then check, if the
condition is satisfied, and execute the desired action.
>
> Anyway, WaitForSingleObject can only be used with an object. There
is also the simply function Sleep(msecs) which could be coded into an
UDF. However, I cannot see why someone would like to block one of the
servers threads until a special condition is met. Better return
control to the client as soon as possible.
>
> Regards, Alex

Triggers would probably be a better solution for him. I would be
careful about using sleep, because from memory (please check this, I
may be wrong but we did encounter this before), sleep acts on every
thread of the program.

If that is the case, then no other thread in firebird would receive
CPU time, and the query it was waiting for would probably never
finish, or at best take an awful long time. WaitForSingleObject has a
timeout parameter, as well as only acting on the current thread. You
could just wait for the firebird process or something like that (which
will always timeout), and set the timeout to 1.5 seconds.

I agree it is risky to sleep in a UDF even if it does work. I can see
a couple of reasons why you would want it, but to me they would put
too much resource demand on the server, and could easily be
transferred to the client application to poll.