11-3. Using E-mail for Job Status Notification

Problem

You have a scheduled job that is running on a regular basis, and you need to know whether the job fails for any reason.

Solution

Use the ADD_JOB_EMAIL_NOTIFICATION procedure to set up an e-mail notification that sends an e-mail when the job fails to run successfully. Note, this solution builds on Recipe 11-1 where a nightly batch job was set up to calculate commissions.

EXEC DBMS_SCHEDULER.ADD_JOB_EMAIL_NOTIFICATION (    -       JOB_NAME=>'nightly_commissions', -     RECIPIENTS=> 'me@my_company.com,dist_list@my_company.com');

How It Works

The previous recipe is the simplest example of automating e-mail in the event a job fails. The ADD_JOB_EMAIL_NOTIFICATION procedure accepts several parameters; ...

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.