Online Documentation for SQL Manager for DB2

Creating/editing trigger


Trigger Editor allows you to set properties for a new trigger or edit an existing trigger.

 

Trigger Editor - Editing trigger definition - Properties

 

 

Use the Schema name drop-down list to select the database schema for the trigger.

 

Use the Trigger name edit box to set the trigger name. Note that the name of the trigger must be unique among all the trigger names in the schema.

 

Select the trigger type (Before, After, Instead of), the schema name and the object of the schema to apply to trigger to, set apply and event modes, and select fields for update.

 

Update fields

To select a field for updating, you need to move it from the Available fields list to the Included fields list. Use the Move all to Selected Move to Selected Move to Available Move all to Available buttons or drag-and-drop operations to move the fields from one list to another.

 

Trigger Editor - Editing trigger definition - WHEN clause

 

 

Specify the WHEN clause and the referencing transitional items using the corresponding tabs of Trigger Editor.

 

Trigger Editor - Editing trigger definition - Referencing

 

 

Transition variables (rows) are used to refer to the values of columns in each updated row of the subject table.

The are two types of transition variables are:

  • Old transition variables capture the values of columns before the triggering SQL statement updates them. You can define old transition variables for update and delete triggers.
  • New transition variables capture the values of columns after the triggering SQL statement updates them. You can define new transition variables for update and insert triggers.

 

If you want to refer to the entire set of rows that a triggering SQL statement modifies, rather than to individual rows, use a transition table. The two types of transition tables are:

  • Old transition tables capture the values of columns before the triggering SQL statement updates them. You can define old transition tables for update and delete triggers.
  • New transition tables capture the values of columns after the triggering SQL statement updates them. You can define new transition variables for update and insert triggers.

 

Triggered SQL statement

This area allows you to set the trigger actions. The trigger actions take effect when the DML operation is performed.