Viewing and Managing Job Queues in Oracle 9i - Page 4January 3, 2003 Ajay Gursahani, ajay.gursahani@mahindrabt.comDBMS_JOB.NEXT_DATEAlters the next execution time for a specified job. DBMS_JOB.NEXT_DATE (JOB IN BINARY_INTEGER,
NEXT_DATE IN DATE);
job - Number of the job being run.
next_date - Date of next refresh.
execute DBMS_JOB.NEXT_DATE(4,SYSDATE+3); If the system date is 15/12/2002, then sysdate+3 is 18/12/2002. SELECT JOB, SUBSTR(WHAT,1,35), NEXT_DATE, NEXT_SEC, INTERVAL FROM DBA_JOBS; JOB SUBSTR(WHAT,1,35) NEXT_DATE NEXT_SEC INTERVAL ----------------------------------------------------------------------- 1 HOUSEKEEP.DEL001; 18/12/2002 12:35:22 sysdate+(59/(24*60*60)) 3 HOUSEKEEP.DEL006; 10/04/2001 01:01:03 sysdate+(59/(24*60*60)) 4 DEPT.DELREC; 18/12/2002 01:01:03 sysdate+(59/(24*60*60)) 5 HOUSEKEEP.DEL004; 10/04/2001 01:01:03 sysdate+(59/(24*60*60)) 4 rows selected. DBMS_JOB.INTERVALAlters the interval between executions for a specified job.
DBMS_JOB.INTERVAL (job IN BINARY_INTEGER,
interval IN VARCHAR2);
job - Number of the job being run.
interval - Character value that specifies the interval as a date expression. If a job should be executed periodically at a set interval, use a date expression similar to 'SYSDATE + 7' in the INTERVAL parameter. Below are some common date expressions used for job execution intervals.
Exactly three days from the last execution
Every half hour
Every minute
Next Day -- Same time as last execution
Every Friday at 3PM
Example: execute DBMS_JOB.INTERVAL(5, 'sysdate+(1/48)'); Changes the interval of the job 5 from every minute to every half hour SELECT JOB, SUBSTR(WHAT,1,35), NEXT_DATE, NEXT_SEC, INTERVAL FROM DBA_JOBS; JOB SUBSTR(WHAT,1,35) NEXT_DATE NEXT_SEC INTERVAL ----------------------------------------------------------------------- 1 HOUSEKEEP.DEL001; 18/12/2002 12:35:22 sysdate+(59/(24*60*60)) 3 HOUSEKEEP.DEL006; 10/04/2001 01:01:03 sysdate+(59/(24*60*60)) 4 DEPT.DELREC; 18/12/2002 01:01:03 sysdate+(59/(24*60*60)) 5 HOUSEKEEP.DEL004; 10/04/2001 01:01:03 sysdate+(1/48) 4 rows selected. Note: When specifying INTERVAL, remember that date literals and strings must be enclosed in single quotation marks. Also, the value of INTERVAL must be enclosed in single quotation marks. The INTERVAL date function is evaluated immediately before a job is executed. When the job completes successfully, the date calculated from INTERVAL becomes the new NEXT_DATE. For example, if you set the execution interval to 'SYSDATE + 7' on Monday, but for some reason, (such as a network failure), the job is not executed until Thursday, 'SYSDATE + 7' then executes every Thursday, not Monday. If the INTERVAL date function evaluates to NULL and the job completes successfully, the job is deleted from the queue. If you always want to automatically execute a job at a specific time, regardless of the last execution, (for example, every Monday), the INTERVAL and NEXT_DATE parameters should specify a date expression similar to 'NEXT_DAY(TRUNC(SYSDATE), "MONDAY")'. |