DBMS_JOB v17
The DBMS_JOB
package's jobs are scheduled and run in the background by the edb_job_scheduler
extension. For more information, see EDB Job Scheduler extension.
The DBMS_JOB
package lets you create, schedule, and manage jobs. A job runs a stored procedure that was previously stored in the database. The SUBMIT
procedure creates and stores a job definition. A job identifier is assigned to a job with a stored procedure and the attributes describing when and how often to run the job.
EDB Postgres Advanced Server's implementation of DBMS_JOB
is a partial implementation when compared to Oracle's version. The following table lists the supported DBMS_JOB
procedures.
Function/procedure | Return type | Description |
---|---|---|
BROKEN(job, broken [, next_date ]) | n/a | Specify that a given job is either broken or not broken. |
CHANGE(job, what, next_date, interval, instance, force) | n/a | Change the job’s parameters. |
INTERVAL(job, interval) | n/a | Set the execution frequency by means of a date function that is recalculated each time the job is run. This value becomes the next date/time for execution. |
NEXT_DATE(job, next_date) | n/a | Set the next date/time to run the job. |
REMOVE(job) | n/a | Delete the job definition from the database. |
RUN(job) | n/a | Force execution of a job even if it's marked broken. |
SUBMIT(job OUT, what [, next_date [, interval [, no_parse ]]]) | n/a | Create a job and store its definition in the database. |
WHAT(job, what) | n/a | Change the stored procedure run by a job. |
When and how often a job runs depends on two interacting parameters: next_date
and interval
. The next_date
parameter is a date/time value that specifies the next date/time to execute the job. The interval
parameter is a string that contains a date function that evaluates to a date/time value.
Before the job executes, the expression in the interval
parameter is evaluated. The resulting value replaces the next_date
value stored with the job. The job is then executed. The expression in interval
is repeatedly reevaluated before each job executes, supplying the next_date
date/time for the next execution.
These examples use the stored procedure job_proc
. The procedure inserts a timestamp into the table jobrun
, which contains a single column, VARCHAR2
.
broken change interval next_date remove run submit what