2 lcm zg lcm_zg 于 2016.05.08 22:12 提问

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个回答

caozhy
caozhy   Ds   Rxr 2016.05.08 23:20
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!