我想在更新后创建一个触发器来更新触发器运行的表。但我不知道选择绕过oracle问题的方法。我已经阅读了不同的意见和建议,但我找不到最好的一个。这就是代码:
CREATE OR REPLACE TRIGGER monitor
AFTER UPDATE OF status
ON action
FOR EACH ROW
DECLARE
actiontype NUMBER (10, 0);
children NUMBER (10, 0);
BEGIN
SELECT code_id
INTO actiontype
FROM action_type
WHERE action_id = :new.action_id
AND projid = :new.projid
AND code_id = 'xxxx';
IF actiontype = xxxx
AND :old.status = 'Active'
AND :new.status = 'Finished'
THEN
SELECT t.action_id
INTO chlidren
FROM action t
LEFT JOIN actionrel tp ON t.action_id = tp.action_id
LEFT JOIN actionactv tsk ON tsk.action_id = t.action_id
LEFT JOIN project p ON p.projid = t.projid
WHERE tp.pred_action_id = :new.action_id
AND t.status = 'TK_NotStart'
AND tsk.code_id = 'xxxx'
AND TRUNC (TO_DATE (p.last_date, 'DD.MON.YYYY')) =
TRUNC (TO_DATE (t.target_date, 'DD.MON.YYYY'));
IF children != NULL
THEN
UPDATE action
SET act_start_date = target_start_date
WHERE action_id = children;
END IF;
END IF;
END;
我可以收到一些提示吗? :)
答案 0 :(得分:0)
提示?是。
为了解决变异表问题,您可以使用
或者,如果可能的话,避免做你正在做的事情。但这要求你改变这个过程。