ORA-04098无效,并且重新验证失败 [英] ORA-04098 is invalid and failed re-validation

查看:123
本文介绍了ORA-04098无效,并且重新验证失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了以下触发器,并成功编译了它。

I wrote the below trigger and it was compiled successfully.

create or replace trigger after_update_datetable
after update on date_table
for each row
begin
   if(TRUNC(:new.end_date) - TRUNC(:new.start_date) > 90) THEN
    UPDATE date_table set END_DATE = :old.END_DATE, START_DATE =  :old.START_DATE;
   END IF;
END;

但是当我执行以下更新语句时,出现此错误

However when I performed the below update statement I got this error

更新date_table设置end_date = sysdate,start_date = sysdate-100;

update date_table set end_date = sysdate, start_date = sysdate-100;

触发失败-ORA-04098无效,并且重新验证失败。

trigger failed -ORA-04098 is invalid and failed re-validation.

感谢您的帮助。谢谢

推荐答案

您正在从触发器更新同一表,但不允许这样做:

you are updating the same table from the trigger, that is not allowed :

if(TRUNC(:new.end_date) - TRUNC(:new.start_date) > 90) THEN
UPDATE date_table set END_DATE = :old.END_DATE, START_DATE =  :old.START_DATE;
END IF;

您最好在BEFORE之前而不是AFTER之前使用触发器,并更新记录的值:NEW
查看此答案,它将对您有用

you better use a trigger for BEFORE instead of AFTER, and update the values of the record :NEW see this answer, it will be useful for you

这篇关于ORA-04098无效,并且重新验证失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆