Pausing Execution
There isn't a delivered way to pause the execution of PeopleCode.
However, there are two alternatives that you can use:
- The
java.lang.Thread.sleep()
Java Class method or; - The
DBMS_LOCK.SLEEP()
database procedure (Oracle only)
Using java.lang.Thread.sleep()
To use this approach, add the following line to your PeopleCode, passing a value in milliseconds which is the amount of time to sleep:
GetJavaClass("java.lang.Thread").sleep(1000);
The code above will sleep for 1000 milliseconds (1 second). Note that this approach still uses up CPU cycles and has a performance hit on the application server. If you find this to be an issue, then the second approach may be better suited if you have an Oracle database.
Using DBMS_LOCK.SLEEP()
SQLExec("exec DBMS_LOCK.SLEEP(1)");
The code above will sleep for 1 second.
1 Comment
I tried the sleep command, and got the below error SQL error. Function: SQLExec Error Position: 6 Return: 6550 - ORA-06550: line 1, column 7: PLS-00201: identifier 'DBMS_LOCK' must be declared OR A-06550: line 1, column 7: PL/SQL: Statement ignored Statement: exec dBMS_LOCK.SLEEP(1) Original Statement: exec dbms_lock.sleep(1)