create or replace trigger trg_pmclinic_pro
after  update
of   rb_proportion
on   pmclinic
for each row
declare
  d_standard_price number(10, 4);
  d_rb_values   number(10, 4); 
    --PRAGMA AUTONOMOUS_TRANSACTION;
begin
  select standard_price
    into d_standard_price
    from  pm_clinic_dict
   where  item_code = :old.item_code;
   
   d_rbrvs_values := d_standard_price * :new.rb_proportion;    
   
    update pmclinic 
    set  rb_values = d_rbrvs_values
    where rb_id = :new.rb_id; 
 
end trg_pmclinic_pro;ORA-04091表发生了变化,触发器/函数不能读它
加上自制事务PRAGMA AUTONOMOUS_TRANSACTION;后又提示等待资源时监测到死锁oracle触发器表发生变化

解决方案 »

  1.   

     更新到
    update pmclinic ....这个地方提示错误
      

  2.   


    SQL> create table t1(id int, name1 varchar2(12), name2 varchar2(12));
    Table created.SQL>
    SQL> create or replace trigger tr_t1
      2  before insert or update on t1
      3  for each row
      4  begin
      5    :new.name2 := :new.name1;
      6  end;
      7  /
    Trigger created.SQL>
    SQL> insert into t1(id, name1) values(1, 'zhangsan');
    1 row created.SQL> update t1 set name1='lisi' where id=1;
    1 row updated.SQL> select * from t1;
            ID NAME1      NAME2
    ---------- ---------- ----------
             1 lisi       lisiSQL>