“插入后” oracle触发器将停止满足特定条件的所有插入。触发器正在检查“ CLASS_TIME”列,如果它小于上午9点或大于下午6点,则更新插入的行。但是该行未完全插入,因此无法更新同一行。下面是触发代码
create or replace TRIGGER ENFORCE_CLASS_TIMINGS
AFTER INSERT ON SYSTEM.TUTPRAC
REFERENCING OLD AS OLD1 NEW AS NEW1
FOR EACH ROW
WHEN (
to_number(to_char(to_date(NEW1.CLASS_TIME,'hh24:mi'),'sssss')) <
to_number(to_char(to_date('09:00', 'hh24:mi'), 'sssss')) OR
to_number(to_char(to_date(NEW1.CLASS_TIME,'hh24:mi'),'sssss')) >
to_number(to_char(to_date('18:00', 'hh24:mi'), 'sssss')))
BEGIN
UPDATE SYSTEM.TUTPRAC
SET STAFFNO = NULL
WHERE
CLASSID = :NEW1.CLASSID;
COMMIT;
END;
请提出解决方法。
尝试以下操作(我将REFERENCING OLD删除为OLD1,因为它在插入触发器中没有任何意义):
create or replace TRIGGER ENFORCE_CLASS_TIMINGS
BEFORE INSERT ON SYSTEM.TUTPRAC
REFERENCING NEW AS NEW1
FOR EACH ROW
WHEN (
to_number(to_char(to_date(:NEW1.CLASS_TIME,'hh24:mi'),'sssss')) <
to_number(to_char(to_date('09:00', 'hh24:mi'), 'sssss')) OR
to_number(to_char(to_date(:NEW1.CLASS_TIME,'hh24:mi'),'sssss')) >
to_number(to_char(to_date('18:00', 'hh24:mi'), 'sssss')))
BEGIN
:NEW1.STAFFNO := NULL;
END;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句