问答详情
源自:2-1 [Oracle] 触发器应用一

触发器没有效果

create or replace trigger securityemp before insert on emp begin  if to_char(sysdate,'day') in ('星期六','星期天') or    to_number(to_char(sysdate,'hh24')) not between 9 and 18 then    --禁止insert新员工    raise_application_error(-20001,'禁止在非工作时间插入新员工'); end if; end; 为什么我用PL/SQL工具编写触发器后,插入语句没有任何效果呢?


http://img4.mukewang.com/6030cf22000108dd11000522.jpg

提问者:回首已是千年 2021-02-20 16:58

个回答

  • 马燊
    2021-06-22 10:42:50

    create or replace trigger no_time_newdate before insert on unifier_uxqa0401

    begin

      if to_char(sysdate,'day') in('saturday','sunday') or to_number(to_char(sysdate,'hh24')) not between 9 and 18

        --禁止insert

        raise_application_error(-20001,'非工作时间禁止写入');

        end if;

    end ;

    我是这样写的,亲测有效