ORACLE触发器中如何终止SQL语句

2025-03-23 06:45:15
推荐回答(2个)
回答1:

create or replace trigger insert_stopbefore insert on tb --tb为你的表名for each rowdeclare insert_excp exception; v_tm varchar2(4);begin v_tm := to_char(sysdate,'hh24mi'); if (to_number(v_tm)>=2200 and to_number(v_tm)<=2359) or v_tm='0000' then raise insert_excp; end if;exception when insert_excp then dbms_output.put_line('在22:00---00:00不可以插入数据'); when others then dbms_output.put_line(sqlcode || ': '||sqlerrm);end;

回答2:

设置时间 到那个时间自动就不执行sql了。就不插了