How to write Triggers? .
The following code shows the creation:
CREATE TRIGGER SALARY_UPDATE BEFORE UPDATE OF SALARAY ON EMP_TABLE FOR EACH ROW MODE DB2SQL WHEN (NEW.SALARY > (OLD.SALARY * 1.5)) BEGIN AUTOMIC SIGNAL SQLSTATE '75001' ('RAISE EXCEEDS 50%'); END
SALARY_UPDATE: Trigger Name
The trigger will fire before actual update. It applies to all update rows. Begin and End are the actual Trigger statements. New value exceeds 50% of old salary. An error will raise. Triggers will be stored in Trigger package. Trigger packages also stored in SYSPACKAGE.