inserted是要插入数据的表么,不能这样写用:new

解决方案 »

  1.   

    create or replace trigger monthreport
      after insert  on bponderation  
      for each row
      declare
    begin
      delete from bmonth
      where bmonth.fmonth=to_char(sysdate,'mm');
    end 
    为什么总时提示  ‘ora-04079 无效的触发器说明’而不能保存我用的是10i
      

  2.   

    将此句
    select count(*) into num
      from bmonth,inserted
       where bmonth.fbreedid=:new.fbreedid 
    改成
     select nvl(sum(1),-1) into num
       from bmonth,inserted
       where bmonth.fbreedid=:new.fbreedid 
    原因,找不到fbreeddid时会触发一个错误,除非你显式用when ...处理否则改动一下语句把,就OK了。
      

  3.   

    create or replace trigger monthreport
      after insert  on bponderation  
      for each row
      declare
      num  number;
    begin
      select count(*) into num
      from bmonth,inserted
       where bmonth.fbreedid=:new.fbreedid ;
      if num>0 then
        insert into bmonth (fyear,fmonth,fcarcount,fbreedid) values(to_char(sysdate,'yyyy'),
        to_char(sysdate,'mm'),'1',:new.fbreedid );
      end if;
    end monthreport;
    /
      

  4.   

    declare和begin之间不能没有内容,此时应该把declare删掉。