我试图触发一个触发器,如果owner_id为null,则在更新或插入owner_notif_sta后将owner_notif_sta设置为null。 owner_id和owner_notif_sta都来自同一个表。
触发器:
CREATE TRIGGER check_owner
AFTER UPDATE OF owner_notif_sta ON risk
REFERENCING OLD AS EXISTING
FOR EACH ROW MODE DB2SQL
UPDATE risk SET owner_notif_sta = NULL
WHERE owner_id IS NULL;
我试图解决的更新:
UPDATE RISK SET owner_notif_sta = 'helloo' WHERE risk_id = 'ICT123';
并且owner_id为null(当我解除更新时未填充)
我收到以下错误: 错误54038:超出了嵌套触发器的最大深度。
提前致谢
答案 0 :(得分:1)
如何稍微更改UPDATE
语句以将已owner_notif_sta
的行排除为null:
CREATE TRIGGER check_owner
AFTER UPDATE OF owner_notif_sta ON risk
REFERENCING OLD AS EXISTING
FOR EACH ROW MODE DB2SQL
UPDATE risk
SET owner_notif_sta = NULL
WHERE owner_id IS NULL
AND owner_notif_sta IS NOT NULL;