我在sensornowvalue这张表上建立了个行触发器
具体实现如下
declare 
Cid varchar2(20);
BDate Date;
TDate Date;
begin
select CoalId into Cid from Sensor where fid = :New.fid;
BDate := :new.updatetime;
TDate := :new.updatetime+0.00035; 
if  :new.status  = '正常' then   
   update Coal set COALSTAT = '正常' where coalid=Cid and 
   not exists ( select  *  from sensornowvalue  where   updatetime between BDate and TDate  and  status not like '%正常%');
end if ;
if (:new.status = '报警') or (:new.status = '超断电值') or  (:new.status = '超量程') then
  update Coal set COALSTAT = '报警' where coalid=Cid;
else
    update Coal set COALSTAT = '异常' where coalid=Cid;
end if;
end;可是当我插入语句的时候老是报错,
错误显示如下
ORA-04091: 表 JINGSHA.SENSORNOWVALUE 发生了变化,触发器/函数不能读
ORA-06512: 在"JINGSHA.COAL_UPDATE", line 10
ORA-04088: 触发器 'JINGSHA.COAL_UPDATE' 执行过程中出错
请高手帮忙分析下

解决方案 »

  1.   

    触发器的完整代码就如上面的
    关键是在after 触发器 好像不让操作本表
      

  2.   

    不是,是从A表中查询!
    从上面的代码可以看出
    ( select  *  from sensornowvalue  where   updatetime between BDate and TDate  and  status not like '%正常%');
    主要就错在这,去掉就对了
      

  3.   

    用视图代替
    http://community.csdn.net/Expert/topic/4973/4973280.xml?temp=.8997614