创建INSERT触发器t_inst_stu:在学生表(student)中每新增一名学生,若其班级编号非空,则将班级表(class)中相应班级的人数(c_total)自动加1。
这是我的代码
create or replace trigger t_inst_stu after insert on student
referencing old as old_value 
     new as new_value 
for each row 
    when (new_value.clsno is not null)
      begin
       update class set c_total=c_total+1 where clsno=:new_value.clsno;
        end;
现在的问题是当执行插入语句时,没反应,求大神指导。

解决方案 »

  1.   

    这个触发器应该是无效的吧   select status from user_objects t where t.object_name='T_INST_STU'   看看状态是什么。  
    另 试试create or replace trigger t_inst_stu after insert on student
    referencing old as old_value 
      new as new_value 
    for each row 
     case when  new_value.clsno is not null then 
      begin
      update class set c_total=c_total+1 where clsno=:new_value.clsno;
      end case;
    end ;
      

  2.   

    不行 显示无效触发器。  我的那个触发器没有错误,现在关键是where clsno=:new_value.clsno;就是new_value.clsno不能将其赋值给clsno、、
      

  3.   

    问题应该是:new_value.clsno在begin...end中不能被识别
      

  4.   

    我改成 
    create or replace trigger t_inst_stu after insert on studentfor each row
    begin 
    case  when :new.clsno is not null then  update class set c_total=c_total+1 where clsno=:new.clsno;
      end case;
    end;你再试试。 这样好像可以。