Understanding DB2®: Learning Visually with Examples
by Raul F. Chong, Clara Liu, Sylvia F. Qi, Dwaine R. Snow
7.13. Triggers
A trigger is a database object associated to a table or a view that contains some application logic, which is executed automatically upon an INSERT, UPDATE, or DELETE operation on the table or view. For example, you can use a trigger:
To validate the input in an INSERT statement
To compare the new value of a row being updated to an old value
To insert logging information to another table for audit trail purposes when a row is deleted
Triggers can be classified as BEFORE, AFTER, or INSTEAD OF triggers.
BEFORE triggers are activated before any table data is affected by the triggering SQL statement. For example, if you are inserting a row into a table, the BEFORE trigger is activated first, before the INSERT is completed.
AFTER triggers ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access