本帖最后由 dschencds 于 2010-06-18 17:53:15 编辑

解决方案 »

  1.   

    create or replace  trigger test_tri
      after insert on user_info
      for each row红色部分
    第一眼看 你的触发器怎么没名了 ,就像人生下来总的有个称呼吧
      

  2.   

    create or replace  test_trigger
    after insert on user_info
    for each row
    declare
    l_name user_info.name%type;
    L_CNT NUMBER:=0;
    --因为你要select的表就是当前的触发表,所以表发生了变异,要使用自制事务
    pragma autonomous_transtraction;
    begin
    select count(*) into L_CNT
    from
    user_info where user_id=1;
    end test_trigger;
    /
      

  3.   

    将你的触发事件改成before 就OK了
    即:after insert on user_info 改成 before insert on user_info
      

  4.   

    改成before 那么后面的事件则不能执行了!因为后面还有一个update语句,是针对插入的数据修改的,在插入之前执行那么这个触发器就没用了
      

  5.   

    create or replace  test_trigger
    after insert on user_info
    for each row
    declare
    l_name user_info.name%type;
    L_CNT NUMBER:=0;
    --因为你要select的表就是当前的触发表,所以表发生了变异,要使用自制事务
    pragma autonomous_transtraction;
    begin
    select count(*) into L_CNT
    from
    user_info where user_id=1;
    commit;--结束该自制事务
    end test_trigger;
    /因为在该触发器中使用到了触发表,而触发表现在处于变异状态,所以从中读取数据时将提示上述信息。