Hi experts,
I am having a hard time coding a trigger to handle multiple validation
conditions in DB2 UDB V8.1.9.. I thought that a single trigger might be
better than one-trigger-per-condition, but so far, no cigar. Here is
what I'd like to do (pseudo-code):
CREATE TRIGGER fp_insert
NO CASCADE BEFORE INSERT
ON DB2INST1.FILE_PROPERTY
REFERENCING NEW AS n
FOR EACH ROW
BEGIN ATOMIC
WHEN (n.property_id = 175 and not exists (select 1 from
DICT_TOO_TRUTH where dict_value = n.property_value))
THEN RAISE_ERROR('70001', 'Error')
WHEN (n.property_id = 187 and not exists (select 1 from
DICT_BIOPSY_TRUTH where dict_value = n.property_value))
THEN RAISE_ERROR('70001', 'Error')
END;
DB2 does not like multiple "WHEN" conditions and I cannot find the
correct syntax for CASE. Can anyone help?
Thanks!
Alejandrina