HP Neoview SQL Reference Manual page 98

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

Trigger Types
You can configure triggers as BEFORE or AFTER types. When a triggering statement occurs, this
is the order of execution:
1.
BEFORE triggered statements
2.
Triggering statement
3.
AFTER triggered statements
Execution of a statement is considered to be complete only when all cascaded triggers are
complete. When multiple triggers are activated by the same event (that is, a conflict set), the next
trigger from the original conflict set is considered only after the execution of cascaded triggers
of a specific trigger is complete (depth-first execution). Within a conflict set, the order of execution
is by timestamp of creation of the corresponding trigger. Older triggers are executed first.
Statement triggers and row triggers can participate in the same conflict set and can cascade each
other. Therefore, they can appear intertwined.
Triggers use transition tables or transition variables to access old and new states of the table or
row. Statement triggers use transition tables. Row triggers use transition variables. This table
summarizes the transition variables that different trigger types can use:
Triggering Event and Activation
Time
BEFORE INSERT
BEFORE UPDATE
BEFORE DELETE
AFTER INSERT
AFTER UPDATE
AFTER DELETE
BEFORE Triggers
BEFORE triggers are used for one of these purposes:
To generate an appropriate signal when an insert, update, or delete operation is applied
and a certain condition is satisfied (using the SIGNAL statement as an action.)
To massage data prior to the insert or update operation that caused the trigger to be activated.
BEFORE-type trigger operations are exercised as tentative executions. The triggering statement
is executed but assigns values to the NEW ROW transition variables rather than to the subject
table. That table appears not to be affected by the tentative execution. When it is accessed by the
trigger action, it shows values in place before the action of the trigger. Because BEFORE-triggers
can only be row triggers, they use transition variables to access old and new states of the row.
Before-type triggers do not modify tables. However, by using a SET statement, they can assign
new values only to the NEW ROW transition variables. As a result, a BEFORE-type trigger can
override the effect of the original triggering statement.
The unique features of BEFORE-type triggers are:
The triggering statement executes only after the trigger is executed.
Only row granularity is allowed.
Only the NEW ROW transition variable can be modified.
BEFORE-type triggers cannot be cascading. A cascading trigger is a trigger whose action
includes trigger events.
One of the key differences between BEFORE- and AFTER-type triggers is their relationship to
constraints. A BEFORE-type trigger can prevent the violation of a constraint, whereas an
AFTER-type trigger cannot, because it is executed after the constraints are checked. BEFORE-type
98
SQL Statements
Row Trigger Can Use:
NEW ROW
OLD ROW, NEW ROW
OLD ROW
NEW ROW
OLD ROW, NEW ROW
OLD ROW
Statement Trigger Can Use:
Invalid
Invalid
Invalid
NEW TABLE
OLD TABLE, NEW TABLE
OLD TABLE

Advertisement

Table of Contents
loading

Table of Contents