5-9. Triggering on a System Event

Problem

You want to write a trigger that executes on a system event such as a login. For example, you want to increase security a bit for your database and ensure that users are logging into the database only during the week. In an effort to help control security, you want to receive an e-mail alert if someone logs into the database on the weekend.

Solution

Create a system-level trigger that will log an event into a table if anyone logs into the database during off-hours. To notify you as promptly as possible, it may also be a good idea to send an e-mail when this event occurs. To create a system-level trigger, use the AFTER LOGON ON DATABASE clause in your trigger definition.

The first step in creating this ...

Get Oracle and PL/SQL Recipes: A Problem-Solution Approach now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.