代码如下:
--确保员工工资不能低于原有工资
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'无效且未通过重新验证”。
请问问题出在哪里,怎样解决?

解决方案 »

  1.   

    视乎报错的触发器跟你这个触发器不一样啊???
    ora-04098:触发器'TSING.TR_DEPT'无效且未通过重新验证”你tr_emp_sal触发器是没问题的,只是你'TSING.TR_DEPT'是干什么的,你检查下
      

  2.   

    'TSING.TR_DEPT'是emp表上的另一个触发器,之前写的时候有报错,具体代码如下:
    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;
      

  3.   

    raise_application_error(-20001,'can’t modify user information in weekend'); --输出错误信息这个  后面抛出的字符串就写错了吧  ,为什么会有三个单引号。还有是:"  当我执行update emp set sal=1000 where empno=7499;语句时,出现“ora-04098:触发器'TSING.TR_DEPT'无效且未通过重新验证”。"
    这个时,说明就是'TSING.TR_DEPT'这个触发器无效,跟你1楼中的触发器是没有关系的。
      

  4.   

    把can't改成can not后触发器就没有弹出“ora-04098:触发器'TSING.TR_DEPT'无效且未通过重新验证”了,不过弹出另一个对话框,提示信息如下:
    ORA-20001:can not modify user information in weekend
    ORA-06512:在"TSING.TR_DEPT",line 3
    ORA-04088:触发器'TSING.TR_DEPT'执行过程中出错
      

  5.   

    是否你的 函数写错了  raise_application_error(-20001,'该用户不允许登录',false);  我的是这样的。