Oracle9i Supplied PL/SQL Packages and Types Reference Release 2 (9.2) Part Number A96612-01 |
|
DBMS_JOB, 2 of 2
This procedure submits a new job. It chooses the job from the sequence sys
.jobseq
.
DBMS_JOB.SUBMIT ( job OUT BINARY_INTEGER, what IN VARCHAR2, next_date IN DATE DEFAULT sysdate, interval IN VARCHAR2 DEFAULT 'null', no_parse IN BOOLEAN DEFAULT FALSE, instance IN BINARY_INTEGER DEFAULT any_instance, force IN BOOLEAN DEFAULT FALSE);
The parameters instance
and force
are added for job queue affinity. Job queue affinity gives users the ability to indicate whether a particular instance or any instance can run a submitted job.
This submits a new job to the job queue. The job calls the procedure DBMS_DDL
.ANALYZE_OBJECT
to generate optimizer statistics for the table DQUON
.ACCOUNTS
. The statistics are based on a sample of half the rows of the ACCOUNTS
table. The job is run every 24 hours:
VARIABLE jobno number; BEGIN DBMS_JOB.SUBMIT(:jobno, 'dbms_ddl.analyze_object(''TABLE'', ''DQUON'', ''ACCOUNTS'', ''ESTIMATE'', NULL, 50);' SYSDATE, 'SYSDATE + 1'); commit; END; / Statement processed. print jobno JOBNO ---------- 14144
This procedure removes an existing job from the job queue. This currently does not stop a running job.
DBMS_JOB.REMOVE ( job IN BINARY_INTEGER );
Parameter | Description |
---|---|
job |
Number of the job being run. |
EXECUTE DBMS_JOB.REMOVE(14144);
This procedure changes any of the user-settable fields in a job.
DBMS_JOB.CHANGE ( job IN BINARY_INTEGER, what IN VARCHAR2, next_date IN DATE, interval IN VARCHAR2, instance IN BINARY_INTEGER DEFAULT NULL, force IN BOOLEAN DEFAULT FALSE);
The parameters instance
and force
are added for job queue affinity. Job queue affinity gives users the ability to indicate whether a particular instance or any instance can run a submitted job.
If the parameters what
, next_date
, or interval
are NULL
, then leave that value as it is.
EXECUTE DBMS_JOB.CHANGE(14144, null, null, 'sysdate+3');
This procedure changes what an existing job does, and replaces its environment.
DBMS_JOB.WHAT ( job IN BINARY_INTEGER, what IN VARCHAR2);
Parameter | Description |
---|---|
job |
Number of the job being run. |
what |
PL/SQL procedure to run. |
Some legal values of what
(assuming the routines exist) are:
'myproc( ''10-JAN-82'', next_date, broken);'
'scott.emppackage.give_raise( ''JENKINS'', 30000.00);'
'dbms_job.remove(job);'
This procedure changes when an existing job next runs.
DBMS_JOB.NEXT_DATE ( job IN BINARY_INTEGER, next_date IN DATE);
Parameter | Description |
---|---|
job |
Number of the job being run. |
next_date |
Date of the next refresh: it is when the job will be automatically run, assuming there are background processes attempting to run it. |
This procedure changes job instance affinity.
DBMS_JOB.INSTANCE ( job IN BINARY_INTEGER, instance IN BINARY_INTEGER, force IN BOOLEAN DEFAULT FALSE);
This procedure changes how often a job runs.
DBMS_JOB.INTERVAL ( job IN BINARY_INTEGER, interval IN VARCHAR2);
Parameter | Description |
---|---|
job |
Number of the job being run. |
interval |
Date function, evaluated immediately before the job starts running. |
If the job completes successfully, then this new date is placed in next_date
. interval
is evaluated by plugging it into the statement select interval
into next_date
from dual;
The interval
parameter must evaluate to a time in the future. Legal intervals include:
Interval | Description |
---|---|
|
Run once a week. |
|
Run once every Tuesday. |
|
Run only once. |
If interval
evaluates to NULL
and if a job completes successfully, then the job is automatically deleted from the queue.
This procedure sets the broken flag. Broken jobs are never run.
DBMS_JOB.BROKEN ( job IN BINARY_INTEGER, broken IN BOOLEAN, next_date IN DATE DEFAULT SYSDATE);
Parameter | Description |
---|---|
job |
Number of the job being run. |
broken |
Job broken: |
next_data |
Date of the next refresh. |
Note: If you set job as broken while it is running, Oracle resets the job's status to normal after the job completes. Therefore, only execute this procedure for jobs that are not running. |
This procedure runs job JOB
now. It runs it even if it is broken.
Running the job recomputes next_date
. See view user_jobs
.
DBMS_JOB.RUN ( job IN BINARY_INTEGER, force IN BOOLEAN DEFAULT FALSE);
EXECUTE DBMS_JOB.RUN(14144);
An exception is raised if force
is FALSE
, and if the connected instance is the wrong one.
This procedure produces the text of a call to re-create the given job.
DBMS_JOB.USER_EXPORT ( job IN BINARY_INTEGER, mycall IN OUT VARCHAR2);
Parameter | Description |
---|---|
job |
Number of the job being run. |
mycall |
Text of a call to recreate the given job. |
This procedure alters instance affinity (8i and after) and preserves the compatibility.
DBMS_JOB.USER_EXPORT ( job IN BINARY_INTEGER, mycall IN OUT VARCHAR2, myinst IN OUT VARCHAR2);
Parameter | Description |
---|---|
job |
Number of the job being run. |
mycall |
Text of a call to re-create a given job. |
myinst |
Text of a call to alter instance affinity. |
|
Copyright © 2000, 2002 Oracle Corporation. All Rights Reserved. |
|