Hi Enuda,
Triggers are meant to be very simple things. Allowing them to become complex entities could result in chaos as the performance degradation of running complex operations could have a devastating affect on DB2.
That said, there is some support for conditional execution. The trigger definition includes the granularity (FOR EACH ROW or FOR EACH STATEMENT), CASE and COALESCE are valid, and the WHEN filter behaves a lot like a nested IF statement.
Here's an example from the IBM documentation that shows how to use the WHEN filter. Perhaps it will suffice for your needs.
CREATE TRIGGER REORDER
AFTER UPDATE OF ON_HAND, MAX_STOCKED ON PARTS
REFERENCING NEW AS N_ROW
FOR EACH ROW
WHEN (N_ROW.ON_HAND < 0.10 * N_ROW.MAX_STOCKED)
BEGIN ATOMIC
VALUES(ISSUE_SHIP_REQUEST(
N_ROW.ON_HAND,
N_ROW.PARTNO));
END
Good Luck,
Kent
Main Topics
Browse All Topics





by: momi_sabagPosted on 2008-07-13 at 09:41:30ID: 21993120
you can not use if inside a trigger
but maybe we can bypass that using a stored procedure or a case statement
what exactly do you need to do?