Summary of Subprograms
Table 17-1 DBMS_JOB Package Subprograms
Subprogram Description
SUBMIT Procedure Submits a new job to the job queue.
REMOVE Procedure Removes specified job from the job queue.
CHANGE Procedure Alters any of the user-definable parameters associated with a job.
WHAT Procedure Alters the job description for a specified job.
NEXT_DATE Procedure Alters the next execution time for a specified job.
INSTANCE Procedure Assigns a job to be run by a instance.
INTERVAL Procedure Alters the interval between executions for a specified job.
BROKEN Procedure Disables job execution.
RUN Procedure Forces a specified job to run.
USER_EXPORT Procedure Recreates a given job for export.
USER_EXPORT Procedure Recreates a given job for export with instance affinity.
SUBMIT Procedure
This procedure submits a new job. It chooses the job from the sequence sys.jobseq. Syntax
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);Parameters
Table 17-2 SUBMIT Procedure Parameters
Parameter Description
job Number of the job being run.
what PL/SQL procedure to run.
next_date Next date when the job will be run.
interval Date function that calculates the next time to run the job. The default is NULL. This must evaluate to a either a future point in time or NULL.
no_parse A flag. The default is FALSE. If this is set to FALSE, then Oracle parses the procedure associated with the job. If this is set to TRUE, then Oracle parses the procedure associated with the job the first time that the job is run. For example, if you want to submit a job before you have created the tables associated with the job, then set this to TRUE.
instance When a job is submitted, specifies which instance can run the job.
force If this is TRUE, then any positive integer is acceptable as the job instance. If this is FALSE (the default), then the specified instance must be running; otherwise the routine raises an exception.
Usage Notes
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. Example
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
----------
14144REMOVE Procedure
This procedure removes an existing job from the job queue. This currently does not stop a running job. Syntax
DBMS_JOB.REMOVE (
job IN BINARY_INTEGER );Parameters
Table 17-3 REMOVE Procedure Parameters
Parameter Description
job Number of the job being run.
Table 17-1 DBMS_JOB Package Subprograms
Subprogram Description
SUBMIT Procedure Submits a new job to the job queue.
REMOVE Procedure Removes specified job from the job queue.
CHANGE Procedure Alters any of the user-definable parameters associated with a job.
WHAT Procedure Alters the job description for a specified job.
NEXT_DATE Procedure Alters the next execution time for a specified job.
INSTANCE Procedure Assigns a job to be run by a instance.
INTERVAL Procedure Alters the interval between executions for a specified job.
BROKEN Procedure Disables job execution.
RUN Procedure Forces a specified job to run.
USER_EXPORT Procedure Recreates a given job for export.
USER_EXPORT Procedure Recreates a given job for export with instance affinity.
SUBMIT Procedure
This procedure submits a new job. It chooses the job from the sequence sys.jobseq. Syntax
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);Parameters
Table 17-2 SUBMIT Procedure Parameters
Parameter Description
job Number of the job being run.
what PL/SQL procedure to run.
next_date Next date when the job will be run.
interval Date function that calculates the next time to run the job. The default is NULL. This must evaluate to a either a future point in time or NULL.
no_parse A flag. The default is FALSE. If this is set to FALSE, then Oracle parses the procedure associated with the job. If this is set to TRUE, then Oracle parses the procedure associated with the job the first time that the job is run. For example, if you want to submit a job before you have created the tables associated with the job, then set this to TRUE.
instance When a job is submitted, specifies which instance can run the job.
force If this is TRUE, then any positive integer is acceptable as the job instance. If this is FALSE (the default), then the specified instance must be running; otherwise the routine raises an exception.
Usage Notes
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. Example
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
----------
14144REMOVE Procedure
This procedure removes an existing job from the job queue. This currently does not stop a running job. Syntax
DBMS_JOB.REMOVE (
job IN BINARY_INTEGER );Parameters
Table 17-3 REMOVE Procedure Parameters
Parameter Description
job Number of the job being run.
解决方案 »
- excel导入oracle时出现的错误,急急急急急!!!
- 怎样根据现存的用户权限创建角色?就是怎样把用户user的权限建成角色?
- 请问,如何采用Thin方式连接Oracle数据库,用VC开发可以吗?
- 关于 全文检索 ftp 或是搜索引擎 能给出思路就行 分全给了 谢谢
- 在pl/sql的command window里运行导出的试图语句出错,在线等待..谢谢
- 可不可以在指定的时间让ORACLE在后台自动编译存储过程?
- 急问:安装到第二碟时,安装程序不走了,退出后重新安装出错
- 如何安裝orcale odbc driver ?急!!!!
- win8.1专业版Database Upgrade Assistant的问题。
- 复杂查询,一条sql多表联合查询 还是 多条sql,循环使用
- 关于SQL写法
- 提供ORACLE Transparent GateWay的下载或资料的来领分!!
EXECUTE DBMS_JOB.REMOVE(14144); CHANGE Procedure
This procedure changes any of the user-settable fields in a job. Syntax
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);Parameters
Table 17-4 CHANGE Procedure Parameters
Parameter Description
job Number of the job being run.
what PL/SQL procedure to run.
next_date Date of the next refresh.
interval Date function; evaluated immediately before the job starts running.
instance When a job is submitted, specifies which instance can run the job. This defaults to NULL, which indicates that instance affinity is not changed.
force If this is FALSE, then the specified instance (to which the instance number change) must be running. Otherwise, the routine raises an exception. If this is TRUE, then any positive integer is acceptable as the job instance.
Usage Notes
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. Example
EXECUTE DBMS_JOB.CHANGE(14144, null, null, 'sysdate+3'); WHAT Procedure
This procedure changes what an existing job does, and replaces its environment. Syntax
DBMS_JOB.WHAT (
job IN BINARY_INTEGER,
what IN VARCHAR2);Parameters
Table 17-5 WHAT Procedure Parameters
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);' NEXT_DATE Procedure
This procedure changes when an existing job next runs. Syntax
DBMS_JOB.NEXT_DATE (
job IN BINARY_INTEGER,
next_date IN DATE);Parameters
Table 17-6 NEXT_DATE Procedure Parameters
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.
INSTANCE Procedure
This procedure changes job instance affinity. Syntax
DBMS_JOB.INSTANCE (
job IN BINARY_INTEGER,
instance IN BINARY_INTEGER,
force IN BOOLEAN DEFAULT FALSE);Parameters
Table 17-7 INSTANCE Procedure Parameters
Parameter Description
job Number of the job being run.
instance When a job is submitted, a user can specify which instance can run the job.
force If this is TRUE, then any positive integer is acceptable as the job instance. If this is FALSE (the default), then the specified instance must be running; otherwise the routine raises an exception.
This procedure changes how often a job runs. Syntax
DBMS_JOB.INTERVAL (
job IN BINARY_INTEGER,
interval IN VARCHAR2);Parameters
Table 17-8 INTERVAL Procedure Parameters
Parameter Description
job Number of the job being run.
interval Date function, evaluated immediately before the job starts running.
Usage Notes
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: 'sysdate + 7'
Run once a week.
'next_day(sysdate,''TUESDAY'')'
Run once every Tuesday.
'null'
Run only once.
If interval evaluates to NULL and if a job completes successfully, then the job is automatically deleted from the queue. BROKEN Procedure
This procedure sets the broken flag. Broken jobs are never run. Syntax
DBMS_JOB.BROKEN (
job IN BINARY_INTEGER,
broken IN BOOLEAN,
next_date IN DATE DEFAULT SYSDATE);Parameters
Table 17-9 Broken Procedure Parameters
Parameter Description
job Number of the job being run.
broken Job broken: IN value is FALSE.
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. --------------------------------------------------------------------------------
RUN Procedure
This procedure runs job JOB now. It runs it even if it is broken. Running the job recomputes next_date. See view user_jobs. Syntax
DBMS_JOB.RUN (
job IN BINARY_INTEGER,
force IN BOOLEAN DEFAULT FALSE);Parameters
Table 17-10 Run Procedure Parameters
Parameter Description
job Number of the job being run.
force If this is TRUE, then instance affinity is irrelevant for running jobs in the foreground process. If this is FALSE, then the job can be run in the foreground only in the specified instance.
Example
EXECUTE DBMS_JOB.RUN(14144);
--------------------------------------------------------------------------------
Caution:
This reinitializes the current session's packages. --------------------------------------------------------------------------------
Exceptions
An exception is raised if force is FALSE, and if the connected instance is the wrong one. USER_EXPORT Procedure
This procedure produces the text of a call to recreate the given job. Syntax
DBMS_JOB.USER_EXPORT (
job IN BINARY_INTEGER,
mycall IN OUT VARCHAR2);Parameters
Table 17-11 USER_EXPORT Procedure Parameter
Parameter Description
job Number of the job being run.
mycall Text of a call to recreate the given job.
USER_EXPORT Procedure
This procedure alters instance affinity (8i and above) and preserves the compatibility. Syntax
DBMS_JOB.USER_EXPORT (
job IN BINARY_INTEGER,
mycall IN OUT VARCHAR2,
myinst IN OUT VARCHAR2);Parameters
Table 17-12 USER_EXPORT Procedure Parameters
Parameter Description
job Number of the job being run.
mycall Text of a call to recreate a given job.
myinst Text of a call to alter instance affinity.
Using the DBMS_JOB Package with Oracle Parallel Server
For this example, a constant in DBMS_JOB indicates "no mapping" among jobs and instances, that is, jobs can be executed by any instance. DBMS_JOB.SUBMIT
To submit a job to the job queue, use the following syntax: DBMS_JOB.SUBMIT( JOB OUT BINARY_INTEGER,
WHAT IN VARCHAR2, NEXT_DATE IN DATE DEFAULTSYSDATE,
INTERVAL IN VARCHAR2 DEFAULT 'NULL',
NO_PARSE IN BOOLEAN DEFAULT FALSE,
INSTANCE IN BINARY_INTEGER DEFAULT ANY_INSTANCE,
FORCE IN BOOLEAN DEFAULT FALSE)
Use the parameters INSTANCE and FORCE to control job and instance affinity. The default value of INSTANCE is 0 (zero) to indicate that any instance can execute the job. To run the job on a certain instance, specify the INSTANCE value. Oracle displays error ORA-23319 if the INSTANCE value is a negative number or NULL. The FORCE parameter defaults to FALSE. If force is TRUE, any positive integer is acceptable as the job instance. If FORCE is FALSE, the specified instance must be running, or Oracle displays error number ORA-23428. DBMS_JOB.INSTANCE
To assign a particular instance to execute a job, use the following syntax: DBMS_JOB.INSTANCE( JOB IN BINARY_INTEGER,
INSTANCE IN BINARY_INTEGER,
FORCE IN BOOLEAN DEFAULT FALSE)
The FORCE parameter in this example defaults to FALSE. If the instance value is 0 (zero), job affinity is altered and any available instance can execute the job despite the value of force. If the INSTANCE value is positive and the FORCE parameter is FALSE, job affinity is altered only if the specified instance is running, or Oracle displays error ORA-23428. If the FORCE parameter is TRUE, any positive integer is acceptable as the job instance and the job affinity is altered. Oracle displays error ORA-23319 if the INSTANCE value is negative or NULL. DBMS_JOB.CHANGE
To alter user-definable parameters associated with a job, use the following syntax: DBMS_JOB.CHANGE( JOB IN BINARY_INTEGER,
WHAT IN VARCHAR2 DEFAULT NULL,
NEXT_DATE IN DATE DEFAULT NULL,
INTERVAL IN VARCHAR2 DEFAULT NULL,
INSTANCE IN BINARY_INTEGER DEFAULT NULL,
FORCE IN BOOLEAN DEFAULT FALSE )
Two parameters, INSTANCE and FORCE, appear in this example. The default value of INSTANCE is NULL indicating that job affinity will not change. The default value of FORCE is FALSE. Oracle displays error ORA-23428 if the specified instance is not running and error ORA-23319 if the INSTANCE number is negative. DBMS_JOB.RUN
The FORCE parameter for DBMS_JOB.RUN defaults to FALSE. If force is TRUE, instance affinity is irrelevant for running jobs in the foreground process. If force is FALSE, the job can run in the foreground only in the specified instance. Oracle displays error ORA-23428 if force is FALSE and the connected instance is the incorrect instance. DBMS_JOB.RUN( JOB IN BINARY_INTEGER,
FORCE IN BOOLEAN DEFAULT FALSE)