7.7. Triggers
A trigger represents a special type of PL/SQL block that you can tie to an event. When a trigger is executed by the Oracle database, it is said to "fire." The most commonly used types of triggers are Data Manipulation Language (DML) triggers that fire in response to INSERT, UPDATE, and DELETE statements. There are 15 different DML trigger types, listed in Table 7-9.
Trigger Event | Triggered for Each | Description |
---|---|---|
BEFORE INSERT | Statement | Executes code before an INSERT statement is executed on the target table |
BEFORE INSERT | Row | Executes code before each row is INSERTed into the target table |
AFTER INSERT | Statement | Executes code after an INSERT statement is executed on the target table |
AFTER INSERT | Row | Executes code after each row is INSERTed into the target table |
INSTEAD OF INSERT | Row | Executes code instead of the INSERT for each row on which an INSERT is attempted |
BEFORE UPDATE | Statement | Executes code before an UPDATE statement is executed on the target table |
BEFORE UPDATE | Row | Executes code before each row of the target table is UPDATEd |
AFTER UPDATE | Statement | Executes code after an UPDATE statement is executed on the target table |
AFTER UPDATE | Row | Executes code after each row of the target table is UPDATEd |
INSTEAD OF UPDATE | Row | Executes code instead of the UPDATE statement for each row for which an UPDATE is attempted |
BEFORE DELETE | Statement | Executes code before a DELETE statement is executed on the target table |
BEFORE DELETE | Row ... |
Get Oracle SQL: the Essential Reference 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.