日期:2014-05-16 浏览次数:20821 次
create or replace trigger hospital14_dui before insert or update or delete on hospital14 when (to_char(sysdate,'hh24') < '08' or to_char(sysdate, 'hh24') > '17') --每天 8 点以前和 17 点以后不得操作表 declare begin raise_application_error(-20001,'a table can not be modified'); end; /
------解决方案--------------------
范围不对哦
create or replace trigger hospital14_dui
before insert or update or delete on hospital14
declare
v_time varchar2(20);
begin
v_time:=to_char(sysdate,'hh24:mi:ss');
if (v_time>'17:00:00' or v_time<'08:00:00')
then
raise_application_error(-20001,'a table can not be modified');
end if;
end;
------解决方案--------------------
那就 to_char(sysdate,'hh24') >= 17
代码是灵活的呀。。