Previous Topic: Define Constraints that are Associated with the TableNext Topic: Define Teradata Users


Define Teradata Table Triggers

A trigger is a stored procedure that executes in response to an event. For example, a trigger can be executed when a row in a table is inserted, updated, or deleted. The trigger tells the DBMS how to process the SQL INSERT, UPDATE, or Delete commands to enforce business rules. You can use the Teradata Table Trigger Editor to define the stored procedures that exist for the selected table in a Teradata physical model.

To define a Teradata table trigger

  1. Expand a Table in the Model Explorer, locate Triggers, right-click a trigger, and then select Properties.

    The Teradata Table Trigger Editor opens.

  2. Work with the following options:

    Note: Click New New icon in property editors to create a new object on the toolbar to create a new trigger.

    Name

    Specifies the name of the trigger.

    Database

    Specifies the database or user to which the trigger belongs. Select from the drop-down list.

    Insert

    Specifies whether to execute the trigger on insert.

    Delete

    Specifies whether to execute the trigger on delete.

    Update

    Specifies whether to execute the trigger on update.

    Fire

    Specifies when the trigger is executed. Select from the drop-down list. Valid values are After, Before, For Each Row, For, or Instead Of.

    Trigger Fire Order

    Specifies the order to fire the triggers.

    Enabled State

    Specifies whether the trigger is enabled or disabled. Select from the drop-down list. Valid values are Enabled and Disabled.

    Use Replace Syntax

    Specifies that Forward Engineering will use the REPLACE command instead of the CREATE command.

    Generate

    Generates DDL for this object during Forward Engineering.

  3. Work with the following fields on the General tab:
    Scope

    Specifies the scope of the trigger. Select from the drop-down list. Valid values are: Row or Statement.

    New

    Indicates the name that you want to use to reference the post-change data in the table. You can use the %RefClause macro to include the REFERENCES clause in the trigger.

    New Table

    Specifies the name for the new row.

    Old

    Indicates the name that you want to use to reference the pre-change data in the table. You can use the %RefClause macro to include the REFERENCES clause in the trigger.

    Old Table

    Specifies the name of the old row.

    When Clause

    Specifies the condition on when to trigger.

    Old New Table

    Specifies the name of the old new transition table.

    Old Value

    Specifies an alias to reference specific old value columns of the row in the old new transition table.

    New Value

    Specifies an alias to reference specific new value columns of the row in the old new transition table.

    Trigger Update

    Displays the valid columns that can have a trigger fired when updated. Select the appropriate columns. This section becomes active when you select to execute the trigger on update.

    Referential Integrity Constraints

    Displays the relationships and tables associated with the trigger.

  4. Work with the other tabs in the editor to access additional design features, for example:
  5. (Optional) Click the Comment tab and enter any comments that you want to associate with the object.
  6. (Optional) Click the UDP tab to work with user-defined properties for the object.
  7. (Optional) Click the Notes tab to view and edit user notes.
  8. Click Close.

    The Teradata Table Trigger Editor closes.

More information:

Edit Code in a Teradata Property Editor

View Expanded Code in a Property Editor

Add a Comment in a Property Editor

Add a UDP in a Physical Property Editor