CREATE_JOB v11
Use the CREATE_JOB
procedure to create a job. The procedure comes in two forms; the first form of the procedure specifies a schedule within the job definition, as well as a job action that will be invoked when the job executes:
The second form uses a job schedule to specify the schedule on which the job will execute, and specifies the name of a program that will execute when the job runs:
Parameters
job_name
job_name
specifies the optionally schema-qualified name of the job being created.
job_type
job_type
specifies the type of job. The current implementation of CREATE_JOB
supports a job type of PLSQL_BLOCK
or STORED_PROCEDURE
.
job_action
If
job_type
isPLSQL_BLOCK
,job_action
specifies the content of the PL/SQL block that will be invoked when the job executes. The block must be terminated with a semi-colon (;).If
job_type
isSTORED_PROCEDURE
,job_action
specifies the optionally schema-qualified name of the procedure.
number_of_arguments
number_of_arguments
is an INTEGER
value that specifies the number of arguments expected by the job. The default is 0
.
start_date
start_date
is a TIMESTAMP WITH TIME ZONE
value that specifies the first time that the job is scheduled to execute. The default value is NULL
, indicating that the job should be scheduled to execute when the job is enabled.
repeat_interval
repeat_interval
is a VARCHAR2
value that specifies how often the job will repeat. If a repeat_interval
is not specified, the job will execute only once. The default value is NULL
.
end_date
end_date
is a TIMESTAMP WITH TIME ZONE
value that specifies a time after which the job will no longer execute. If a date is specified, the end_date
must be after start_date
. The default value is NULL
.
Please note that if an end_date
is not specified and a repeat_interval
is specified, the job will repeat indefinitely until it is disabled.
program_name
program_name
is the name of a program that will be executed by the job.
schedule_name
schedule_name
is the name of the schedule associated with the job.
job_class
job_class
is accepted for compatibility and ignored.
enabled
enabled
is a BOOLEAN
value that specifies if the job is enabled when created. By default, a job is created in a disabled state, with enabled
set to FALSE
. To enable a job, specify a value of TRUE
when creating the job, or enable the job with the DBMS_SCHEDULER.ENABLE
procedure.
auto_drop
The auto_drop
parameter is accepted for compatibility and is ignored. By default, a job's status will be changed to DISABLED
after the time specified in end_date
.
comments
Use the comments
parameter to specify a comment about the job.
Example
The following example demonstrates a call to the CREATE_JOB
procedure:
The code fragment creates a job named update_log
that executes each weeknight at 5:00. The job executes a PL/SQL block that inserts the current timestamp into a logfile (my_log
). Since no end_date
is specified, the job will execute until it is disabled by the DBMS_SCHEDULER.DISABLE
procedure.