现有表test(id,a,b,c,d,e,f)  表A(id,a,c)  表B(id,b,d)   表C(id,e,f)
如何用存储过程把test表的数据分别插入到ABC3张表中   

解决方案 »

  1.   

    规则是啥?insert into a (select id,a,c from test);这样全部插入?
      

  2.   

    参考:
    create or replace pr_insert is
    begin
       insert into a (select id,a,c from test);
       insert into b (select id,b,d from test);
       insert into c (select id,e,f from test);
     
       
    end;
      

  3.   

    如果A表里的字段test表没有怎么默认给值
      

  4.   

    首先明确一下你的需求,是一次性的,还是每次insert test都有这样的要求。如果是一起性的迁移表的话,有很多的选择,直接用sql就可以搞定,不需要用sp,比如insert all,或者一个一个的insert,merge如果是后者主要的话,用after triger for each row。当然trigger里用以上的sql。
      

  5.   

    是这样的   我有一张test表字段比方说有20个字段吧
    现在因为扩展,想把test表拆分为3个表 这3张表中可能会增加几个字段,所以有的字段test中没有,
    现需要把test表中的数据相应的插入到那3张表中 如果是新增加的字段则存入空值 
      

  6.   

    看了半天,不想回答这个问题,总之LZ的sql写少了,让你每天写一个存储过程,保证你不会遇到这样的问题