《SQL Server数据库实用案例教程》 实验13 游标使用练习 -参考代码-不要先发学生.docx





《《SQL Server数据库实用案例教程》 实验13 游标使用练习 -参考代码-不要先发学生.docx》由会员分享,可在线阅读,更多相关《《SQL Server数据库实用案例教程》 实验13 游标使用练习 -参考代码-不要先发学生.docx(2页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、提示:不要把答案先发给学生,实验结束后再公布答案。要让学生先自己思考做题,老师对学生不会的题目适当提示,一题题解决困惑。实验13游标使用练习参考代码/*继续使用实验创建的银行储蓄数据库,客户信息(customerinfo)表、账户信息(accountinfo)表、交易信息(transInfo)表三个表的表结构见表易信表-20。*/(1)题修改实验12创建的触发器,使用游标-创建触发器的代码:-创建触发器的代码:CREATE TRIGGER tr_upye_curON transInfoAFTER INSERTASBEGINSET NOCOUNT ON;declare c_tr cursor f
2、or-新名字上加cur表示用游标一建在 transInfo 表-响应insert事件,后触发-必须有的关键字-屏蔽几行受影响的信息-1声明游标select accountID, transType, transMoney from inserted declare jylx char(4),zh varchar(19),jyje decimal(20,2) open c_tr-2打开游标fetch from c_tr into zh, jylx, jyje -3 读取游标数据存入变量 while fetch_status = 0-用全局变量判读读取成功则循环beginif jylx大支取,-判
3、断是存款还是取款update accountinfo set accountMoney = accountMoney - jyje WHERE accountID=zh将取款卡奈额减少elseupdate accountinfo set accountMoney = accountMoney + jyjeWHERE accountID=zh-将存款卡荼额增加fetch from c_tr into zh, jylx, jyje 一再次读取游标数据 endclose c_tr-4关闭游标deallocate c_tr-5 释放游标END对象资源肯理器,X行(。),寄机 团总 Q 9 LAPTOP
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- SQL Server数据库实用案例教程 SQL Server数据库实用案例教程 实验13 游标使用练习 -参考代码-不要先发

链接地址:https://www.taowenge.com/p-96867022.html
限制150内