Advertisement
Advertisement


How to wait for 2 seconds?


Question

How does one cause a delay in execution for a specified number of seconds?

This doesn't do it:

WAITFOR DELAY '00:02';

What is the correct format?

2019/04/25
1
193
4/25/2019 3:37:52 PM

Accepted Answer

The documentation for WAITFOR() doesn't explicitly lay out the required string format.

This will wait for 2 seconds:

WAITFOR DELAY '00:00:02';

The format is hh:mi:ss.mmm.

2011/10/06
377
10/6/2011 3:06:44 PM


How about this?

WAITFOR DELAY '00:00:02';

If you have "00:02" it's interpreting that as Hours:Minutes.

2011/10/06

Try this example:

exec DBMS_LOCK.sleep(5);

This is the whole script:

SELECT TO_CHAR (SYSDATE, 'MM-DD-YYYY HH24:MI:SS') "Start Date / Time" FROM DUAL;

exec DBMS_LOCK.sleep(5);

SELECT TO_CHAR (SYSDATE, 'MM-DD-YYYY HH24:MI:SS') "End Date / Time" FROM DUAL;
2019/03/12

Source: https://stackoverflow.com/questions/7676164
Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Email: [email protected]