Oracle DBMS_JOB Version 21c |
---|
General Information | ||||||||||||||||||||||
Library Note |
|
|||||||||||||||||||||
Purpose | This package is deprecated and has been supplanted by DBMS_SCHEDULER. If you have any code using this package it is recommended that you move it to DBMS_SCHEDULER as part of migrating to 12c or above. | |||||||||||||||||||||
AUTHID | CURRENT_USER | |||||||||||||||||||||
Constants |
|
|||||||||||||||||||||
Dependencies |
|
|||||||||||||||||||||
Documented | Yes: Packages and Types Reference | |||||||||||||||||||||
Exceptions |
|
|||||||||||||||||||||
First Available | 7.3.4 | |||||||||||||||||||||
Job Intervals | Execute daily 'SYSDATE + 1' |
|||||||||||||||||||||
Security Model | Owned by SYS with EXECUTE granted to PUBLIC | |||||||||||||||||||||
Source | {ORACLE_HOME}/rdbms/admin/dbmsjob.sql | |||||||||||||||||||||
Subprograms | ||||||||||||||||||||||
BACKGROUND_PROCESS | ||||||||||||||||||||||
Indicates whether execution is a background process or foreground process For internal use only |
dbms_job.background_process RETURN BOOLEAN; |
|||||||||||||||||||||
set serveroutput on |
||||||||||||||||||||||
BROKEN | ||||||||||||||||||||||
How a job becomes 'broken' | Oracle has failed to successfully execute the job after 16 attempts. or You have marked the job as broken, using the procedure DBMS_JOB.BROKEN Once a job has been marked as broken, Oracle will not attempt to execute the job until it is either marked not broken, or forced to be execute by calling the DBMS_JOB.RUN. |
|||||||||||||||||||||
Force a job to broken status | dbms_job.broken ( |
|||||||||||||||||||||
-- break one job |
||||||||||||||||||||||
The following example marks job 14144 as not broken and sets its next execution date to - - the following Monday | exec dbms_job.broken(14144, FALSE, NEXT_DAY(SYSDATE, 'MONDAY')); |
|||||||||||||||||||||
Force a broken job to run and fix it | exec dbms_job.broken(JOB=>&job_no, NEXT_DATE=>SYSDATE + &when_plus_sysdate, broken=>FALSE); |
|||||||||||||||||||||
CHANGE | ||||||||||||||||||||||
Change A Job's Attributes | dbms_job.change( |
|||||||||||||||||||||
exec dbms_job.change(14144, NULL, NULL, 'SYSDATE + 3'); |
||||||||||||||||||||||
INSTANCE | ||||||||||||||||||||||
Assign a specific instance to execute a job | dbms_job.instance( |
|||||||||||||||||||||
SELECT instance_number |
||||||||||||||||||||||
INTERVAL | ||||||||||||||||||||||
Reset the job interval | dbms_job.interval( |
|||||||||||||||||||||
-- use TRUNC(SYSDATE) to keep the job interval from drifting. |
||||||||||||||||||||||
ISUBMIT | ||||||||||||||||||||||
Submit a job with a user specified job number | dbms_job.isubmit ( |
|||||||||||||||||||||
exec dbms_job.isubmit(4242, 'MYPROC', SYSDATE); |
||||||||||||||||||||||
IS_JOBQ | ||||||||||||||||||||||
Undocumented Thank you Laszlo Vincze for the correction |
dbms_job.is_jobq RETURN BOOLEAN; |
|||||||||||||||||||||
set serveroutput on |
||||||||||||||||||||||
NEXT_DATE | ||||||||||||||||||||||
Reset next execution date and time for a job | dbms_job.next_date( |
|||||||||||||||||||||
exec dbms_job.next_date(134, SYSDATE + 1/24); |
||||||||||||||||||||||
REMOVE | ||||||||||||||||||||||
To remove a job in the job queue | dbms_job.removejob IN BINARY_INTEGER); |
|||||||||||||||||||||
SELECT job |
||||||||||||||||||||||
RUN | ||||||||||||||||||||||
Force a job to run immediately and, if it was broken, reset it to not broken | dbms_job.run( |
|||||||||||||||||||||
exec dbms_job.run(job_no); |
||||||||||||||||||||||
SUBMIT | ||||||||||||||||||||||
Submit Parameters | JOB An output parameter, this is the identifier assigned to the job you created. You must use this jobnumber whenever you want to alter or remove the job. WHAT This is the PL/SQL code you want to have executed. The WHAT parameter must end with a semi-colon. NEXT_DATE The next date when the job will be run. The default value is SYSDATE. INTERVAL The date function that calculates the next time to execute the job. The default value is NULL. INTERVAL must evaluate to a future point in time or NULL. This parameter is a VARCHAR2 and must be enclosed in single quotes. NO_PARSE This is a flag. If NO_PARSE is set to FALSE (the default), Oracle parses the procedure associated with the job. If NO_PARSE is set to TRUE, Oracle parses the procedure associated with the job the first time that the job is executed. If, for example, you want to submit a job before you have created the tables associated with the job, set NO_PARSE to TRUE. |
|||||||||||||||||||||
Submit a job with a job number selected from sys.jobseq Many thanks for Kieron Hardy for contributing these examples. |
dbms_job.submit( |
|||||||||||||||||||||
DECLARE |
||||||||||||||||||||||
USER_EXPORT | ||||||||||||||||||||||
Produces the text of a call to re-create the given job Overload 1 |
dbms_job.user_export( |
|||||||||||||||||||||
SELECT job |
||||||||||||||||||||||
Alters instance affinity (8i and after) and preserves compatibility Overload 2 |
dbms_job.user_export ( |
|||||||||||||||||||||
set serveroutput on |
||||||||||||||||||||||
WHAT | ||||||||||||||||||||||
Change a job's definition | dbms_job.what( |
|||||||||||||||||||||
exec dbms_job.what(42, 'YOURPROC'); |
||||||||||||||||||||||
Demos | ||||||||||||||||||||||
Job Scheduling Demonstration | CREATE TABLE job_table (
exec job_call |
|||||||||||||||||||||
Related Queries | ||||||||||||||||||||||
Jobs Running | SELECT r.sid, r.job, r.this_date, r.this_sec, SUBSTR(what,1,40) what |
|||||||||||||||||||||
User Jobs | col job format 99999 |
Related Topics |
Built-in Functions |
Built-in Packages |
DBMS_AUTOTASK_ADMIN |
DBMS_IJOB |
DBMS_SCHEDULER |
Table Triggers |
What's New In 21c |
What's New In 23c |
This site is maintained by Dan Morgan. Last Updated: | This site is protected by copyright and trademark laws under U.S. and International law. © 1998-2023 Daniel A. Morgan All Rights Reserved | |||||||||
|
||||||||||