Managing Named Programs

I’ve explained two basic scheduling concepts: the job and the schedule. A third important concept is the program: the actual code that will be executed as scheduled. Now that you’ve learned how to call different types of programs, you might be tempted (quite justifiably) to place all scheduled processes —whether in stored procedures, PL/SQL anonymous blocks, or operating system executables—under Scheduler control. There is, however, one complication that you will need to be aware of. According to the syntax you’ve seen so far, you need to pass the full path of your executable (or your PL/SQL block or stored procedure) to the parameter job_action in the CREATE_JOB procedure. If the path is long (as it may often be), it may be inconvenient to specify the entire path. And if you supply it more than once, you are again introducing opportunities for errors to enter your scheduling process.

Fortunately, DBMS_SCHEDULER allows you to define named programs, which make it extremely easy to reference the program to be executed. Named programs are essentially synonyms for the actual code being executed. Instead of calling the actual code segment, you simply reference the name you have given the program. Then, if you ever need to change your job to run a different program, you will not need to change the job definition. All you have to do is swap the new executable into the program, and your job will call the right one.

Get Oracle PL/SQL for DBAs now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.