代码如下:
--确保员工工资不能低于原有工资
Create or replace trigger tr_emp_sal
before update of sal on emp
for each row
begin
if :new.sal<:old.sal then
raise_application_error(-20010,'sal should not be less');
end if;
end;当我执行update emp set sal=1000 where empno=7499;语句时,出现“ora-04098:触发器'TSING.TR_DEPT'无效且未通过重新验证”。
请问问题出在哪里,怎样解决?
--确保员工工资不能低于原有工资
Create or replace trigger tr_emp_sal
before update of sal on emp
for each row
begin
if :new.sal<:old.sal then
raise_application_error(-20010,'sal should not be less');
end if;
end;当我执行update emp set sal=1000 where empno=7499;语句时,出现“ora-04098:触发器'TSING.TR_DEPT'无效且未通过重新验证”。
请问问题出在哪里,怎样解决?
ora-04098:触发器'TSING.TR_DEPT'无效且未通过重新验证”你tr_emp_sal触发器是没问题的,只是你'TSING.TR_DEPT'是干什么的,你检查下
create or replace trigger tr_dept
before insert or update or delete on emp
begin
if to_char(sysdate,'DY','nls_date_language=AMERICAN')in('SAT','SUN') then --取出当前日期的星期并用AMERICAN显示
raise_application_error(-20001,'can’t modify user information in weekend'); --输出错误信息
end if;
end;
这个时,说明就是'TSING.TR_DEPT'这个触发器无效,跟你1楼中的触发器是没有关系的。
ORA-20001:can not modify user information in weekend
ORA-06512:在"TSING.TR_DEPT",line 3
ORA-04088:触发器'TSING.TR_DEPT'执行过程中出错