Triggers Wizard (DB2 Z/OS)

From DBArtisan
Jump to: navigation, search

Go Up to IBM DB2 for z/OS Object Wizards

All data in a database is stored in a tabular format, that is a collection of rows and columns. Tables, therefore are fundamental to whatever database you are administering.

To create a new trigger using a wizard:

  1. Open a creation wizard for a trigger. For details, see Opening an Object Wizard.
  2. Use the following topics as a guide to setting properties and performing tasks as you pass through the wizard panels:
  3. Finally, use the Execute button to create the object.

Triggers (DB2 z/OS) - 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

BEFORE: These triggers serve as extensions to the constraint subsystem and are most often used to validate input data, generate values for newly inserted rows, and read from other tables for cross-reference purposes. Note: Before triggers must be created as a For Each Row. AFTER: Such a trigger is run after the integrity constraint validations; they can be used to modify operations in the database or be used for activities beyond the database, like supporting an alert notification.

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 will not be 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

STATEMENT: (only fires once). ROW (fires for each affected row): The trigger runs as many times as there are rows in the affected section. If the set of affected rows is empty, the trigger doesn’t run.

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’ve been deleted or updated.

New Row Alias

Type a name for the rows as they are after they’ve been inserted or updated.

Triggers (DB2 z/OS) - Column Selection

If you chose UPDATE as the Trigger Event, select the columns, select the check box beside each column that is to fire the trigger.

Triggers (DB2 z/OS) - Definition

Complete the CREATE TRIGGER outline provided by typing or pasting the body of the trigger.