Friday, May 25, 2018

Oracle Database 12c -- Using Oracle Scheduler Metadata Variables in Jobs

Problem

You need to access the Scheduler metadata environment within a job, like the job name, job owner etc.


Solution

Oracle scheduler provides some predefined metadata variables which can be used in a PL/SQL block or a program to access the Oracle scheduler environment:

Metadata Attribute Datatype Description
job_name VARCHAR2 Name of the currently running job
job_subname VARCHAR2 Subname of the currently running job. The name + subname form a unique identifier for a job that is running a chain step. NULL if the job is not part of a chain.
job_owner VARCHAR2 Owner of the currently running job
job_scheduled_start TIMESTAMP WITH TIME ZONE When the currently running job was scheduled to start
job_start TIMESTAMP WITH TIME ZONE When the currently running job started
window_start TIMESTAMP WITH TIME ZONE If the job was started by a window, the time that the window opened
window_end TIMESTAMP WITH TIME ZONE If the job was started by a window, the time that the window is scheduled to close


All metadata attributes can be used in PL/SQL blocks that you enter into the job_action or program_action attributes of jobs or programs, respectively. You use the attribute name as you use any other PL/SQL identifier, and the Scheduler assigns it a value.

No comments: