TZMLAY 2016-05-08 14:12 采纳率: 100%
浏览 1163
已采纳

oracle 触发器 插删改

 create or replace trigger TG_attend_417
before delete or insert or update on attend_417
for each row
begin
    if inserting then 
        update stud set sum_evaluation = sum_evaluation-2*(select count(*)from attend_417 where (attendance = 'la')-5*(select count(*)from attend_417 where attendance = 't')-1*(select count(*)from attend_417 where attendance = 'le')
        where sno=:new.sno;
    end if;
    if deleting then
        update stud set sum_evaluation = sum_evaluation-2*(select count(*)from attend_417 where (attendance = 'la')-5*(select count(*)from attend_417 where attendance = 't')-1*(select count(*)from attend_417 where attendance = 'le')
        where sno = :old.sno;
    end if;
    if updating then 
        update stud set sum_evaluation = sum_evaluation-2*(select count(*)from attend_417 where (attendance = 'la')-5*(select count(*)from attend_417 where attendance = 't')-1*(select count(*)from attend_417 where attendance = 'le')
        where sno = :old.sno;
    end if;
end;

这是代码,la表示迟到,扣2分,t表示旷课,扣5分,le表示请假,扣1分,attendance 表示出勤类别

请问要怎么修改才是正确的?

  • 写回答

1条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?