1 / 3
文档名称:

数据库存储过程与触发器实验报告.doc

格式:doc   大小:58KB   页数:3页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

数据库存储过程与触发器实验报告.doc

上传人:taoapp 2021/10/31 文件大小:58 KB

下载得到文件列表

数据库存储过程与触发器实验报告.doc

文档介绍

文档介绍:南昌航空大学实验报告
二00 年 月 日
课程名称: 数据库概论实验名称:数据库存储过程与触发器
班级:122031姓名: 同组人:
指导教师评定: 签名:
实验环境
Windows2000或以上版本;
SQLServer2005。
实验目的
熟悉不同数据库的存储过程和触发器,重点实践SQL Server2005,掌握SQL Server2005中有存储过程与触发器的相关知识。
实验要求
完成实验指导书中p115-7和p132 -4。
实验步骤及参考源代码

create procedure C_P_Proc as
select distinct ,cna,pna,num
from paper,customer,cp
where = and = and cna='李涛' or cna='钱金浩' go
execute C_P_Proc

drop procedure C_P_Proc

create trigger TR_PAPER_I ON PAKER12203125
FOR INSERT AS
DECLARE ***@appr float
DECLARE ***@apno int
SELECT ***@appr=ppr,***@apno=pno from inserted
begin
if ***@appr<0 or ***@appr is null
begin
raiserror('报纸的单价为空或小于!',16,1)
update paper set ppr=10
where =***@apno
end
end

create Trigger TR_PAPER_D on PAKER12203125
after delete as
declare ***@ipno char(6)
declare ***@icount int;
select ***@icount= count(*) from deleted,cp
where =
if ***@icount>=1
begin
select ***@ipno=pno
from deleted
raiserror('级联删除cp表中的数据',16,1)
delete from cp where =***@ipno
end

create trigger TR_PAPER_U ON PAKER12203125
for update as
declare ***@ippr float
select ***@ippr=ppr from inserted
if ***@ippr<0