11-1. Scheduling Recurring Jobs

Problem

You want to schedule a PL/SQL procedure to run at a fixed time or at fixed intervals.

Solution

Use the EXEC DBMS_SCHEDULER.CREATE_JOB procedure to create and schedule one-time jobs and jobs that run on a recurring schedule. Suppose, for example, that you need to run a stored procedure named calc_commissions every night at 2:30 a.m. to calculate commissions based on the employees' salaries. Normally, commissions would be based on sales, but the default HR schema doesn't provide that table, so we'll use an alternate calculation for demonstration purposes:

EXEC DBMS_SCHEDULER.CREATE_JOB (    -     JOB_NAME=>'nighly_commissions', -     JOB_TYPE=>'STORED_PROCEDURE',   -     JOB_ACTION=>'calc_commisions',  - ...

Get Oracle and PL/SQL Recipes: A Problem-Solution Approach 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.