The Triggered Action specifies a list of SQL statements to execute
when a trigger is activated. The BEFORE, FOR EACH ROW, and AFTER sections
of the Action Clause can each specify different list of triggered
actions for the same trigger.
For a trigger on a table, the trigger action consists of an optional
WHEN condition and the action statements. You can specify a triggered-action
list for each WHEN clause, or you can specify a single list (of one
or more trigger actions) if you include no WHEN clause.
Database objects that are referenced explicitly in the trigger
action or in the definition of the trigger event, such as tables,
columns, and UDRs, must exist when the CREATE TRIGGER statement defines
the new trigger.
The
following Update trigger includes no WHEN clause, but invokes the
SPL routine upd_items_p1( ) as its triggered action whenever
the quantity column of the items table is updated:
CREATETRIGGER up_itemqty
UPDATEOF quantity ON items
BEFORE(EXECUTEPROCEDURE upd_items_p1);
If no upd_items_p1(
) routine is registered in the database when this CREATE TRIGGER
statement is issued, the database server issues an error, and no up_itemqty trigger
is created.
Attention: When you specify a date
expression in the WHEN condition or in an action statement, make sure
to specify four digits instead of two digits for the year. For more
about abbreviated years, see the description of DBCENTURY in
the HCL OneDB™ Guide to SQL:
Reference,
which also describes how the behavior of some database objects can
be affected by environment variable settings. Like fragmentation expressions,
check constraints, and UDRs, triggers are stored in the system catalog
with the creation-time settings of environment variables that can
affect the evaluation of expressions like the WHEN condition. The
database server ignores any subsequent changes to those settings when
evaluating expressions in those database objects.
Have feedback?
Google Analytics is used to store comments and ratings. To provide a comment or rating for a topic, click Accept All Cookies or Allow All in Cookie Preferences in the footer of this page.