实验四--触发器的使用(共3页).doc
《实验四--触发器的使用(共3页).doc》由会员分享,可在线阅读,更多相关《实验四--触发器的使用(共3页).doc(3页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、精选优质文档-倾情为你奉上实验四 触发器的使用 4实验目的1、理解触发器基本概念。2、掌握触发器定义及其触发。3、了解触发器调试。4、理解触发器作用。实验内容1、定义一个触发器,完成及时计算所有供应商供应零件总数量。create or replace trigger t1_spjafter insert or delete or update on spjdeclarecursor cur_1 is select sno ,sum(qty) as sumqty from spj group by sno; begin for cur in cur_1 loop update s set sqt
2、y=cur.sumqty where s.sno=cur.sno; end loop; end t1_spj;insert into spj values(S5,P6,J4,700); 2、定义触发器,实现实体完整性(以s表供应商代码sno为例)。create or replace trigger t2_spjafter insert on sdeclarev_sno s.sno%type;v_count number;cursor cur_sno is select sno from s group by sno having count(*)1;begin select count(*)
3、into v_count from s where sno is null; if v_count0 then raise_application_error (-20008,主码sno不能取空值); end if; open cur_sno; fetch cur_sno into v_sno; if cur_sno%found then raise_application_error (-20012,主码sno不能重复); end if; end t2_spj;insert into S(SNO,SNAME,STATUS,CITY) values(S1,竟仪,20,天津); 3、定义触发器,
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 实验 触发器 使用
限制150内