I recently converted CRONTAB jobs to DBMS_SCHEDULER. Partially motivated the fact I’m in the database more than I’m on the Linux box, and security of not having to use passwords and but mostly because it makes since. If I’m going to schedule a job that is going to access the database why not schedule it within the database. I have even done this for the exports.
I still want to be notified should the job fail, but could also receive notification when it starts and finishes.
Here are the steps I used:
1. Setup the necessary attributes such as the SMTP server and the email address to use as From:
2. Next create the job (if its not already created
job_action=>’BEGIN DATABASE_EXPORT; END;’,
repeat_interval => ‘Freq=daily; byminutely=0’
3. Next associate the notification with the job just created (or already existing)
# Additionally I can add to events as such ‘job_started,job_succeeded,job_failed’ or any combination.
Just remember that the entire value must be enclosed in single ticks.
4. A filter condition can also be added so that on job_failed only certain oracle errors will trigger the
# the event.error_code can include whatever combination of oracle errors minus any leading zeros.
Notifications can be viewed via the dba_scheduler_notifications view.
To remove notifications: