CREATE OR REPLACE TRIGGER NEW_TRIG INSERT ON TABLE_NAME FOR EACH ROW
declare
begin
  update table_name set name='xxxxxx' where id=:new.id;
end;
好象没看到after关键字?
insert on 前是不是该加个after

解决方案 »

  1.   

    insert on 前是有个after,刚忘写了,不是错在这里,
      

  2.   

    可以编译通过,但是插入值的时候就出现上面的问题,
    我用的是oracle9.2
      

  3.   

    没有,就只有这一个触发器
    并且就执行insert
    各位高手帮忙,帮我看看这是什么问题,
    如果不能用,在after insert怎么引用插入的值
      

  4.   

    create procedure update_pro(p_id in varchar2)
    as
    begin
    update table_name set name='xxxxxx' where id=p_id;
    end;
    /CREATE OR REPLACE TRIGGER NEW_TRIG INSERT ON TABLE_NAME FOR EACH ROW
    begin
      update_pro(:new.id);
    end;
      

  5.   

    你是不是對表本身在進行update?CREATE OR REPLACE TRIGGER NEW_TRIG INSERT ON TABLE_NAME FOR EACH ROW
                                                 ~~~~~~~~~~
    declare
    begin
      update TABLE_NAME set name='xxxxxx' where id=:new.id;
             ~~~~~~~~~~
    end;要是這樣的話那肯定不行啊﹖要不是這樣呢﹐再看看
      

  6.   

    这个我来试试,那上面到底是什么原因呢,
    new在after insert中用,我看好多书都这样写的,难道说真有问题
      

  7.   

    很明顯是在trigger 里update了基本表本身﹐這是不行的幫你查了一下出錯的原因﹕
    ORA-04091: table name is mutating, trigger/function may not see itCause: A trigger or a user-defined PL/SQL function that is referenced in the   statement attempted to query or modify a table that was in the middle of being modified by the statement that fired the trigger.Action: Rewrite the trigger or function so it does not read the table.
      

  8.   

    :NEW 只有在delete triger中不能用﹐其它的都可以
      

  9.   

    好象不是吧,我是trigger中写了一个select语句中,用到了:new,同样也报这个错
      

  10.   

    FOR EACH ROW
    不能对同一个表进行触发
      

  11.   

    上面的方法试了,很抱歉,不可以,这个时候错转到procedure 中了,也同样的错
      

  12.   

    我是说 触发的表与被触发的表应该是不同的表
    for each row保留
      

  13.   

    我在after事件中也无法引用new,改成before不会出错,但无法改变name值