我的项目中需要写一个oracle触发器,其要求是:在储过程中写一条insert语句,然后将刚插入的后的ID查询出来插入到一条insert语句,请教:该触发器该如何写? 
 

解决方案 »

  1.   

    ID序列是自增的?你的意思就是要看插入的记录返回的ID?
      

  2.   

    嗯,是要将插入的记录返回的ID再报告文学入到下一条insert语句中
      

  3.   

    噢,不好意思,打错字了。应该是将插入的记录返回的ID再插入到下一条insert语句中
      

  4.   

    aaa t.a%type;
    insert into t (a,...)
    values(...)
    returning a into aaa;
      

  5.   

    可否写完整些?因为刚学习oracle所以对于您写的还不太明白
      

  6.   

    aaa t.id%type; --定义t表id字段类型插入t表
    insert into t (id) 
    values(seq.NEXTVAL) 
    returning id into aaa;--赋值給aaa 
    insert into t1 (id)
    values(aaa)-- 用aaa的值插入另一个表
      

  7.   

    create or replace procedure pro(参数列表)
    IS
    BEGIN 
    aaa t.id%type; --定义t表id字段类型 
    insert into t (id) 
    values(seq.NEXTVAL) 
    returning id into aaa;--赋值給aaa 
    insert into t1 (id) 
    values(aaa)-- 用aaa的值插入另一个表 
    END;   
    请教:是这样写吗?
      

  8.   

    IS 
    aaa t.id%type;
    BEGIN 

    commit;
    exception
    when others  then
         rollback;

    END;