Skip to Main Content
Oracle PL/SQL for DBAs
book

Oracle PL/SQL for DBAs

by Arup Nanda, Steven Feuerstein
October 2005
Intermediate to advanced content levelIntermediate to advanced
454 pages
14h 44m
English
O'Reilly Media, Inc.
Content preview from Oracle PL/SQL for DBAs

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.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Oracle PL/SQL Best Practices

Oracle PL/SQL Best Practices

Steven Feuerstein
Expert Oracle PL/SQL

Expert Oracle PL/SQL

Ron Hardman, Michael McLaughlin
Oracle PL/SQL For Dummies

Oracle PL/SQL For Dummies

Michael Rosenblum, Paul Dorsey

Publisher Resources

ISBN: 0596005873Supplemental ContentErrata Page