IBM Books

Embedded SQL Programming Guide


Overview of a Trigger

A trigger is a schema object associated with a base table and with an event that corresponds to an update operation on the base table (denoted as the subject table). The term update operation is used here to denote any change to the state of the subject table, regardless of whether that change was initiated by an SQL INSERT, UPDATE, DELETE, or an action of a referential constraint. When such an update operation (denoted as the triggering operation) is executed, the trigger is said to be activated. Once activated, the set of rows in the subject table that are affected by the update operation are determined and the action of the trigger is executed. During execution, the trigger action condition is tested and if satisfied, the triggered SQL statements are executed. Such an execution can take place before or after the update operation (or trigger event) and either only once for the update operation or for each row affected by the operation. A trigger can be defined using the CREATE TRIGGER statement. For details of the CREATE TRIGGER statement, see the SQL Reference.

When a trigger is created, the following items are defined for the trigger:


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]

[ DB2 List of Books | Search the DB2 Books ]