oracle写个存储过程,往一个表中加数据,数据的部分字段是从另一个表来的,还有部分字段是入参进去的,这个存储过程要怎么写

解决方案 »

  1.   

    这能玩出什么花来么……insert into xxx select yyy字段1,yyy字段2...参数1,参数2... from yyy where zzz...
      

  2.   


    insert就两种样子:一种就是前面写的,一种就insert into xxx values (.....); 看着办吧~
      

  3.   

    declare 
      TYPE dq_row IS TABLE OF dq_tmbh%ROWTYPE; 
      data1 dq_row;
      
      cursor dq_cs is
      select id as tmbh from dqzb_20170810 ;
      
    begin
      open dq_cs;
      loop
      fetch dq_cs bulk collect into data1 limit 1000;
        if data1.COUNT > 0 then
          forall i in data1.first .. data1.last
            insert into  dq_tmbh  values data1(i);
          commit;
        end if;
        exit when dq_cs%notfound;
      end loop;
    end;给你个insert模板,相应的改一下就可以
      

  4.   

    你给点东东出来啊。
    r如果一部分来自其它表,加个游标。create or replace pro_t1 (in_1 varchar2,in_2 varchar2) is
    begin
    declare
    cursor cur_t1 is select m1,m2 from t2 where m1=1;
    type_t1 cur_t1%rowtype;
    begin
    open cursor cur_t1
    fetch cur_t1 into type_t1;
    insert into t2 (p1,p2,p3,p4) values (type_t1.m1,type_t1.m2,in_1,in_2);
    close cur_t1;
    end;
    end ;