我写的触发器:
create or replace trigger TRI_SYSHISTORY
  after insert on case_info 
  for each row
  declare
  v_num integer;
begin
  select count(id) into v_num from case_history where id=(select id from (select id  from  case_info order by id desc)  where rownum = 1);
  if v_num=0 then
     insert into case_history  
                select *  from  (select *  from  case_info order by id desc)  where rownum = 1;
  end if;
end TRI_SYSHISTORY;
说明:case_info为表A,case_history为表B。请帮忙看看,谢谢

解决方案 »

  1.   

    称序报错:
    java.sql.SQLException: ORA-04091: 表 FCPS.CASE_INFO 发生了变化,触发器/函数不能读
      

  2.   

    感觉lncf(锋) 说对了,怎么该?
      

  3.   

    为什么不用 :new.id
    ------------------這個才對了
      

  4.   

    不对,代码根本走不到用id的地方就报错,ORA-06512: 在"FCPS.TRI_SYSHISTORY", line 6
    第6行。
      

  5.   

    问题解决,触发器不能对行级执行sql语句
      

  6.   

    对了,改成对表级操作就行了,
    也就是把for  each  row  这行删除就ok了