Databases Reference
In-Depth Information
Creating programs manually
A program is defined using the CREATE_PROGRAM procedure from the
DBMS_SCHEDULER package. It requires us to specify the program name, owner, type
of program, and argument definition. The program can be created in an enabled
status from the beginning, but in this case the program is enabled once the complete
configuration task is finished.
To create a program based on an already existing program unit:
BEGIN
DBMS_SCHEDULER.CREATE_PROGRAM(
program_name =>'OSCHEDULER.LOG_INFO_PROG',
program_action =>'OSCHEDULER.INS_JOB_LOG_ENTRY',
program_type =>'STORED_PROCEDURE',
number_of_arguments=>1,
comments =>'Log Info Stored Procedure Program',
enabled =>FALSE);
END;
Once the program is created, the next step is to define the required arguments:
BEGIN
DBMS_SCHEDULER.DEFINE_PROGRAM_ARGUMENT(
program_name =>'OSCHEDULER.LOG_INFO_PROG',
argument_name =>'LOG_INFO',
argument_position=>1,
argument_type =>'VARCHAR2',
default_value =>'',
out_argument =>FALSE);
END;
And finally the program is enabled.
BEGIN
DBMS_SCHEDULER.ENABLE(
name=>'OSCHEDULER.LOG_INFO_PROG');
END;
The following piece of code shows the way to create an OS program using
DBMS_SCHEDULER .
In this piece of code a simple shell script is scheduled. The script executes an echo
and redirects the output to an OS file:
echo 'date' Log Entry Generated from the OS > /tmp/OracleJob.log
 
Search WWH ::




Custom Search