当前位置:Gxlcms > 数据库问题 > 【Oracle 触发器】(3) 触发器应用场景--复杂的安全性检查

【Oracle 触发器】(3) 触发器应用场景--复杂的安全性检查

时间:2021-07-01 10:21:17 帮助过:8人阅读

--触发器应用场景1: 复杂的安全性检查 2 --禁止在非工作时间插入新员工 3 /* 4 1.周末:to_char(sysdate,‘day‘) in(‘星期六‘,‘星期日‘) 5 2.上班前,下班后:to_number(to_char(sysdate,‘hh24‘)) not between 9 and 18 6 */ 7 8 create or replace trigger securityemp 9 before insert --插入前触发 10 on emp1 11 declare 12 begin 13 14 if to_char(sysdate,day)in (星期六,星期日) or 15 to_number(to_char(sysdate,hh24)) not between 9 and 18 then 16 --禁止insert新员工 17 raise_application_error(-20001,禁止在非工作时间插入新员工); 18 end if; 19 end; 20 /

测试:

1 insert into emp1(empno,ename,sal,deptno) values(1001,Tom,3000,10);

 

结果:

技术图片

 

【Oracle 触发器】(3) 触发器应用场景--复杂的安全性检查

标签:create   tween   end   mamicode   code   before   http   星期六   oracle   

人气教程排行