本人现在在做一个新增页面功能,但新增记录要插入到多个表中,这种情况如何在存储过程中实现呀,请各位高手指点。

解决方案 »

  1.   

    将要输入的字段做为存储过程的输入参数
    然后insert into就行了create or replace procedure pname(a varchar2,b varchar2,c int)
    as
    begin
      insert into t1...;
      ....
      insert into tn...;
      commit;
    exception
      rollback;
      ......
    end;
      

  2.   

    就直接写多个insert就可以了吗?我是新手,不知道如何实现,以前只插入过一张表
      

  3.   

    多个表就用多个insert就行了。有关联性的表注意一下事务的控制就行了。
      

  4.   


    create or replace procedure ps_test()
    as
    begin
    --first
      begin
      insert into table1.....;
      commit;
      exception
      rollback;
      ....
      end;
      begin
      insert into table1.....;
      commit;
      exception
      rollback;
      ....
      end;
    --second
      begin
      insert into table2.....;
      commit;
      exception
      rollback;
      ....
      end;................
    end;
      

  5.   

    有多少表要插就写几个INSERT就好了  或者写个轮询
      

  6.   


    是不是只是对事务的要求。如果是,在所有的insert完后commit,在异常时rollback就可以了
    ================================================================== 
    Inthirties关注Oracle数据库 维护 优化,安全,备份,恢复,迁移,故障处理 如果你需要帮助或想和我一起学习的请联系 
    联系方式QQ:370140387 
    QQ群:  85837884(注明:数据库) 
    电子邮件:[email protected] 
    网站: http://www.inthirties.com