In some situations, you may need to create a stored subprogram that will be invoked implicitly when a certain action occurs. For example, you might need to create a procedure that will be invoked whenever a certain DML operation (INSERT, UPDATE
, or DELETE
) is issued against a given table or view. You can also choose a combination of DML operations, each of which will fire the procedure. To handle such tasks, the Oracle database offers triggers.
Note
A database trigger is an event-driven stored subprogram that is invoked automatically in response to a certain event.
The following sections discuss how to create a trigger on a database table. This is the most common use of triggers. In chapter 6
Security, you'll see an example of a system trigger created on the LOGON
event, to be fired whenever a user is connected to the database.