Creating a Program
In this next example, I’ll use DBMS_SCHEDULER’s CREATE_PROGRAM procedure to give a frequently called executable program the name KICK_RMAN_INC.
BEGIN
DBMS_SCHEDULER.create_program
(program_name => 'KICK_RMAN_INC',
program_type => 'EXECUTABLE',
program_action => '/u01/app/oracle/admin/tools/kick_rman_inc.sh',
enabled => TRUE,
comments => 'Take RMAN Inc Backup'
);
END;After the program is created, my original RMAN incremental backup job will not need to specify the full path of the program or what type of job it is. The new definition looks like this:
BEGIN
DBMS_SCHEDULER.create_job (job_name => 'RMAN_INC',
program_name => 'KICK_RMAN_INC',
schedule_name => 'EVERY_DAY',
comments => 'RMAN Inc Backup',
enabled => TRUE
);
END;Note that I’ve specified only the schedule name and the program name. Because the program (with its whole path) has already been defined as an executable, there is no need to specify what type of program it is (PL/SQL block, stored procedure or executable), so the program_type parameter is no longer needed in the job description. Furthermore, now that this program has been defined, you can also use it in another job without specifying any details. You can even change the job entirely—for example, make it a PL/SQL block or a stored procedure instead of an OS executable—and you will not have to change any of the code that creates the job.