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 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题