当前位置:Gxlcms > 数据库问题 > PL/SQL&存储过程||存储函数&触发器

PL/SQL&存储过程||存储函数&触发器

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

实施复杂的安全性检查 禁止在非工作时间插入新员工 非工作时间: 1. 周末: to_char(sysdate,‘day‘) in (‘星期六‘,‘星期日‘) 2. 上班前 下班后:to_number(to_char(sysdate,‘hh24‘)) not betweeen 9 and 18 */ 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 --抛出错误 raise_application_error(-20001,禁止在非工作时间插入新员工); end if; end; /
--涨后的工资不能少于涨前的工资

create or replace trigger checksal
before update
on emp
for each row
begin

  --if 涨后的薪水 <  涨前的薪水 then 
  if :new.sal < :old.sal then
    raise_application_error(-20002,涨后的工资不能少于涨前的工资.涨后:||:new.sal||   涨前:||:old.sal);
  end if;

end;
/

 

PL/SQL&存储过程||存储函数&触发器

标签:

人气教程排行