好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

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

实施复杂的安全性检查 禁止在非工作时间插入新员工 非工作时间: 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&存储过程||存储函数&触发器

标签:

查看更多关于PL/SQL&存储过程||存储函数&触发器的详细内容...

  阅读:22次

上一篇: sql-like

下一篇:sql-数据库的隔离级别