【2017年整理】instead of 触发器例子

上传人:爱****1 文档编号:990012 上传时间:2017-05-24 格式:DOC 页数:2 大小:24.50KB
返回 下载 相关 举报
【2017年整理】instead of 触发器例子_第1页
第1页 / 共2页
【2017年整理】instead of 触发器例子_第2页
第2页 / 共2页
亲,该文档总共2页,全部预览完了,如果喜欢就下载吧!
资源描述

《【2017年整理】instead of 触发器例子》由会员分享,可在线阅读,更多相关《【2017年整理】instead of 触发器例子(2页珍藏版)》请在金锄头文库上搜索。

1、(1)create view view_emp_deptas select empno,ename,dept.deptno,dname,job,hiredatefrom emp,deptwhere emp.deptno = dept.deptno;(2)create or replace trigger tri_insert_viewinstead of inserton view_emp_dept-创建一个关于 view_emp_dept 视图的替换触发器for each row-是行级视图declarerow_dept dept%rowtype;beginselect * into row

2、_dept from dept where deptno = :new.deptno;-检索指定部门编号的记录行if sql%notfound then-未检索到该部门编号的记录insert into dept(deptno,dname)values(:new.deptno,:new.dname);-向 dept 表中插入数据end if;insert into emp(empno,ename,deptno,job,hiredate)values(:new.empno,:new.ename,:new.deptno,:new.job,:new.hiredate);-向 emp 表中插入数据end tri_insert_view;/(3)向视图中执行 insert 语句触发存储过程。

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号