WHEN Condition
The WHEN condition makes the triggered action dependent on the
outcome of a test. When you include a WHEN condition in a triggered
action, the statements in the triggered action list execute only if
the condition evaluates to true
. If the WHEN condition
evaluates to false
or unknown
, then
the statements in the triggered action list are not executed.
CREATE TRIGGER up_price
UPDATE OF unit_price ON stock
REFERENCING OLD AS pre NEW AS post
FOR EACH ROW WHEN(post.unit_price > pre.unit_price * 2)
(INSERT INTO warn_tab VALUES(pre.stock_num, pre.order_num,
pre.unit_price, post.unit_price, CURRENT));
An SPL routine that executes inside the WHEN condition carries the same restrictions as a UDR that is called in a data manipulation statement. That is, the SPL routine cannot contain certain SQL statements. For information on which statements are restricted, see Restrictions on SPL Routines in Data-Manipulation Statements.