create or replace trigger securityemp
before insert
on cc
for each row begin
if to_char(sysdate,'day') in ('星期六','星期日','星期五') or
to_number(to_char(sysdate,'hh24')) not between 9 and 18 then
raise_application_error(-20202,'规定时间不允许插入');
end if;
end;这样就ok了
before insert
on cc
for each row begin
if to_char(sysdate,'day') in ('星期六','星期日','星期五') or
to_number(to_char(sysdate,'hh24')) not between 9 and 18 then
raise_application_error(-20202,'规定时间不允许插入');
end if;
end;这样就ok了
before insert
on emps
declare
out_worktime exception;
begin
if to_char(sysdate,'day') in ('星期六','星期日','星期五') or
to_number(to_char(sysdate,'hh24')) not between 9 and 18 then
raise out_worktime;
end if;
exception
when out_worktime then
dbms_output.put_line('do not insert data during non-work time');
raise_application_error(-20202,'规定时间不允许插入');
end;
/
异常不能在触发器里处理掉,需要向外抛才能终端插入操作
学习啦