How do I create PL/SQL function which waits for update on some row for specified timeout and then returns.
What I want to accomplish is – I have long running process which will update it’s status to ASYNC_PROCESS table by process_id. I need function which returns with true/false when this process has completed, but also I need this function to wait some time for this process complete, return on timeout or return imediately with true, when process has completed. I don’t want to use sleep(1 sec), because in such case I will be having 1 sec lag. I don’t want to use sleep(1 msec), because in such case I am spending cpu resources (and 1msec lag).
Is there a good way how experienced programmer would accomplish this?
That function will be called from .NET (So I need minimal lag between DB operation and .NET/UI)
THNX,
Beef
I think the most sensible thing to do in this case is to use update triggers on that
ASYNC_PROCESStable.You should also look into the
DBMS_ALERTpackage. Here’s an edited excerpt from that doc:Create an alert:
Create a trigger on your table to fire the alert:
From your
.netcode, you can the use something that calls this:Make sure you read the docs for what
:statusand:timeoutdo.