Thursday 8 September 2011

How do I pause a PLSQL program

Question:

I'm using a trigger on insert in order to create a flat file on a remote machine, using the dbms_file package.
In case of network error ("dbms_file can't create file"), I would like to wait a few moments and try again. Is there a "delay" function/package in PL/SQL?

Answer:

Ivanka: You will find nestled away in the DBMS_LOCK package a program named SLEEP. I bet you can figure out the rest, but as long as I am writing about it...the header for this program is:
DBMS_LOCK.SLEEP (seconds IN NUMBER);
You can specify a value with precision down to the hundredth of a second. So, for example, if I would like to pause my PL/SQL program for 2/100ths of a second, I would execute this code:
DBMS_LOCK.SLEEP (.02);
I am not aware of a maximum limit for the amount of time you can pass to DBMS_LOCK.

No comments:

Post a Comment