Triggers Wizard (DB2 LUW)
Go Up to IBM DB2 for Linux, Unix, and Windows Object Wizards
A trigger defines a set of actions that take place in conjunction with, or are triggered, for a particular base table, with an insert, update, or delete statement. Triggers are good ways to validate input data, read from other tables for cross-referencing purposes, and other similar purposes. The Trigger wizard lets you create a trigger without requiring you to know any of the underlying commands.
To create a new trigger using a wizard
- Open a creation wizard for a trigger. For details, see Opening an Object Wizard.
- Use the following topics as a guide to setting properties and performing tasks as you pass through the wizard panels:
- Properties panel. For details, see Triggers (DB2 LUW) - Properties.
- Column Selection panel. For details, see Triggers (DB2 LUW) - Column Selection.
- Definition panel. For details, see Triggers (DB2 LUW) - Definition.
- Click Execute to create the object.
Triggers (DB2 LUW) - Properties
When creating or editing a trigger, this tab/panel lets you work with the following settings:
| Setting | Description |
|---|---|
|
Table Schema and Table Name |
Choose the owner and name of the table for which the trigger is being created. |
|
Schema and Name |
Choose the owner and name of the trigger being created. |
|
Trigger Timing |
|
|
Trigger Events |
An INSERT trigger must be associated with an INSERT statement. For example, if a data load operation doesn't include an INSERT statement, the trigger is not invoked. An UPDATE trigger can be associated with specific columns of the base table and will only be activated if those columns are updated. |
|
Trigger Type |
|
|
Old Table Alias |
Type the name of a temporary table of rows as they exist before they're updated or deleted. |
|
New Table Alias |
Type a name for a temporary table of rows as they exist after they're inserted or updated. |
|
Old Row Alias |
Type a name for the rows as they are before they are deleted or updated. |
|
New Row Alias |
Type a name for the rows as they are after they are inserted or updated. |
Triggers (DB2 LUW) - Column Selection
If you chose UPDATE as the Trigger Event, select the columns, and then select the check box next to each column that is to fire the trigger.
Triggers (DB2 LUW) - Definition
Complete the CREATE TRIGGER outline provided by typing or pasting the body of the trigger.