暂无图片
触发器可以触发多表吗?
我来答
分享
暂无图片 匿名用户
触发器可以触发多表吗?

触发器可以触发多表吗?

我来答
添加附件
收藏
分享
问题补充
1条回答
默认
最新
刘贵宾

可以。例如,师生互动平台,教务处部分,删除学生的时候,许多其他表中也会有studentid这个字段,那么,如果单纯的删除basic_info_student表中的该学生,下一次,许多表在遍历的时候,就会出现,找不到学生基本信息的情况。此时,解决办法就涉及到多表触发


create or replace trigger studelete
after DELETE
ON basic_info_student
for each row
BEGIN delete from ELECOURSE_INFO_USER where Vstudentid=:old.Vstudentid;
update agreestudent set Vstudentid='0000001' where Vstudentid=:old.Vstudentid;
delete from apply_list where Vstudentid=:old.Vstudentid;
delete from discuss_App where Vstudentid=:old.Vstudentid;
delete from DM_ask where studentid=:old.Vstudentid;
delete from Dm_bbs where studentid=:old.Vstudentid;
delete from Dm_discuss where studentid=:old.Vstudentid;
delete from Dm_dminfo where studentid=:old.Vstudentid;
delete from Dm_interact where studentid=:old.Vstudentid;
delete from Dm_logon where studentid=:old.Vstudentid;
delete from Dm_qsearch where studentid=:old.Vstudentid;
delete from ELECOURSE_INFO_USER where Vstudentid=:old.Vstudentid;
update label_lesson set Vstudentid='0000001' where Vstudentid=:old.Vstudentid;
update Posts set Vpersonid='0000001' where Vpersonid=:old.Vstudentid and Ipersontype='11';
delete from ptcourse_info_user where Vstudentid=:old.Vstudentid;
update question_list set Vstudentid='0000001' where Vstudentid=:old.Vstudentid;
update Replypost set Vpersonid='0000001' where Vpersonid=:old.Vstudentid and Ipersontype='11';
update sms_list set Vsenderid='0000001' where Vsenderid=:old.Vstudentid and ISenderType='11';
delete from student_file where Vstudentid=:old.Vstudentid;
delete from student_sms where Vstudentid=:old.Vstudentid;
END studelete;

暂无图片 评论
暂无图片 有用 0
打赏 0
暂无图片
回答交流
Markdown


请输入正文
提交
相关推荐
sql server 的alwayson 一直卡在这里,怎么解决?
回答 2
用你MSSQLERVER服务的登录账号登录执行  telnetIP1433看一下端口是否通。最好用第一种创建方案。
STANDBY备库 做的RMAN增量备份,假设主备库同时挂掉,怎么用备库的RMAN增量备份 恢复成主库?
回答 2
只在控制文件里面记录了主备库的身份,数据文件是不区分主备库的,只要控制文件备份好了,互相restore都是可以的
tdsql富文本大字段 text类型可以存储吧?
回答 1
注意mysql中几种text类型的长度限制和字符集;
国产数据库有没有在国外的应用案例?
回答 6
很少吧,目前还是用国外的多
状态是recover数据文件怎么彻底删除?
回答 1
要进行恢复。如果说不要了,要offline才能删除
Hubble数据库支持哪些编程语言?
回答 1
天云Hubble数据库支持Java、C/C、GO、Python、Ruby、Js(node.js)、PHP、Rust等所有的常用的编程语言.
去o,本来package里做的处理,有什么替代方案吗?
回答 3
目前国产的达梦、openGauss等数据库,支持createpackage语法。我实测将以前我以前在oracle中开发的部分package代码直接打在达梦或者openGauss数据库(2.1.0版本d
OushuDB中怎么设置Virtual Segment内存使用
回答 1
VSEGRESOURCEQUOTA指的是一个virtualsegment中使用的内存数量。默认值是256MB。比如一个资源管理队列可以使用的资源是8GB,如果VSEGRESOURCEQUOTA为256
数据库 在存储过程中插入查询数据,为什么没有插进去?
回答 1
存储过程中的SQL语句有误,导致插入失败。存储过程中的变量名或表名拼写错误。存储过程中的变量类型不匹配,导致插入失败。存储过程中的游标没有正确使用,导致插入失败。
数据库监听表的数据变化,但不想用触发器和 listen notify,有其他成熟方案吗?
回答 1
除了使用触发器和Listen/Notify之外,还有其他一些成熟的方案可用来监听表的数据变化。以下是一些常见的方案:1.轮询查询(PollingQuery):定期查询表中的数据,比较前后的数据差异来检