Question: How do I use the
dbms_lock.sleep procedure? Can you give an
example script using dbms_lock.sleep?
Answer: The dbms_lock.sleep
procedure directs a PL/SQL anonymous code snippet or stored
procedure (or function) to stop for a specified period of n
seconds.
PROCEDURE DBMS_LOCK.SLEEP
Here is an example of using dbms_lock.sleep in PL/SQL:
The slow_function.sql script below
creates an artificially slow function by using the
dbms_lock.sleep procedure to sleep for 20 seconds. For this
to work successfully the user must be granted execute
permission on the dbms_lock package.
slow_function.sql
CREATE OR REPLACE FUNCTION slow_function (p_number IN
NUMBER)
RETURN BOOLEAN AS
BEGIN
--
Mimic a slow function.
DBMS_LOCK.sleep(20);
RETURN TRUE;
END;
/
SHOW ERRORS