oracle 触发器学习
来源:互联网 发布:mac 水波纹特效 编辑:程序博客网 时间:2024/05/18 19:45
触发器(trigger)是个特殊的存储过程,它的执行不是由程序调用,也不是手工启动,而是由个事件来触发,比如当对一个表进行操作( insert,delete, update)时就会激活它执行。
1、插入数据后输出一句话
--每当成功插入新员工后,自动打印"成功插入新员工"create trigger abcdafter inserton empdeclarebegin dbms_output.put_line('成功插入新员工');end;/
2、语句级触发器
/*触发器应用一:实施复杂的安全性检查禁止在非工作时间插入新员工周末:to_char(sysdate,'day') in ('星期六','星期日')上班前 下班后:to_number(to_char(sysdate,'hh24')) not between 9 and 17*/create or replace trigger securityempbefore inserton empbegin if to_char(sysdate,'day') in ('星期六','星期日','星期三') or to_number(to_char(sysdate,'hh24')) not between 9 and 17 then --禁止insert raise_application_error(-20001,'禁止在非工作时间插入新员工'); end if;end;/3、行级触发器
/*触发器应用二: 数据的确认涨后的工资不能少于涨前的工资*/create or replace trigger checksalarybefore updateon empfor each rowbegin --if 涨后的薪水 < 涨前的薪水 then if :new.sal < :old.sal then raise_application_error(-20002,'涨后的工资不能少于涨前的工资。涨前:'||:old.sal||' 涨后:'||:new.sal); end if;end;/
阅读全文
0 0
- oracle触发器学习
- Oracle 学习笔记 触发器
- oracle 触发器学习笔记
- Oracle触发器学习
- Oracle触发器学习笔记
- Oracle 触发器学习
- oracle触发器学习(一)
- oracle触发器学习
- oracle 触发器 学习笔记
- oracle数据库触发器学习
- oracle触发器学习
- oracle触发器学习
- oracle触发器学习笔记
- ORACLE触发器学习
- ORACLE触发器学习
- oracle 触发器学习
- oracle 触发器学习
- oracle学习笔记_触发器
- http://blog.csdn.net/UW63ZqpKxwlRL1/article/details/78682401
- 剑指offer---把字符串转换为整数(49)
- Dubbo-Admin管理平台和Zookeeper注册中心的搭建
- 注释转换项目
- SpringBoot学习:从入门到熟悉
- oracle 触发器学习
- 使用GDB的源代码查看功能
- 谈谈索引
- 行是知之始,知是行之成
- C语言学习历程(十一)二维数组与指针的关系
- CodeForces
- FreeMarker优点和缺点与使用FreeMarker的10个理由
- 这10大科技,将彻底改变你的生活
- linux系统之网络防火墙(firewalld服务和iptables服务)