oracle - need to insert data all together into temp table -
hi here sample code .
i need insert data both procedures rather 1 after one..this code inserts data 1st first procedure , second row number 1st has ended inserting.please suggest way can insert data , not sequentially.
create or replace package body procedure main_proc(param1 number,param2 number,v1 out number,v2 out number) v_resultset help.cursortype-->this defined in package spec v_name varchar2(10); v_code varchar2(40); begin v1:=param1; v2:=param2; proc1(v1,v_resultset); loop fetch v_resultset v_name; exit when v_resultset%notfound; dbms_output.put_line('error in proc1'); insert temp_table(name) values(v_name) ; end loop; proc2(v1,v2,v_resultset); loop fetch v_resultset v_code; exit when v_resultset%notfound; dbms_output.put_line('error in proc2'); insert temp_table(code) values(v_code) ; end loop; end main_proc; proc1(v_name varchar2,r_resultset out help.cursortype) begin open r_resultset select name emp dept_id=2; end; proc2(v_name varchar2,v_code varchar2,r_resultset out help.cursortype) begin open r_resultset select code code_table dept_id=3; end; end help;
i need insert data instead of sequentially global temp table.
this procedure inserts data below : name code
clark (null)
jones (null) smith (null) adam (null) (null) 001 (null) 002 (null) 003 (null) 004
whereas want inserted
name code clark 001 jones 002 smith 003
adam 004
procedure packagecategory_info(p_item_cat number,p_item_sub_cat number,p_pack_cat_id number,package_sub_cat number,pc_resultset out master_product_report.cursortype) begin if p_item_sub_cat null , p_pack_cat_id null , package_sub_cat null open pc_resultset select name packagecategory itemcategory_id in (select id itemcategory start id=p_item_cat connect prior id=parent_id); elsif p_pack_cat_id null , package_sub_cat null open pc_resultset select name packagecategory itemcategory_id in (select id itemcategory parent_id not null start id=p_item_sub_cat connect prior id=parent_id); elsif package_sub_cat null open pc_resultset select name packagecategory start id=p_pack_cat_id connect prior id=parent_id , level_id !=3; else open pc_resultset select name packagecategory id=package_sub_cat; end if; end packagecategory_info; ----- main procedure in above proc called create or replace package body master_product_report procedure product_report (p_item_cat number,p_sub_cat number,p_pack_cat_id number,p_pack_sub_cat_id number,p_pack_id number,v1 out number,v2 out number,v3 out number,v4 out number,v5 out number) ---------- --some code-- packagecategory_info(v1,v2,v3,v4,v_resultset); loop fetch v_resultset v_pack_cat_name; exit when v_resultset%notfound; dbms_output.put_line('error in proc2'); insert master_product_table(package_sub_cat_name) values(v_pack_cat_name) ; end loop;
if got right:
proc1(v1, v_names); proc2(v1, v2, v_codes); loop fetch v_names v_name; fetch v_codes v_code; exit when v_names%notfound; exit when v_codes%notfound; insert temp_table(name, code) values(v_name, v_code); end loop; close v_names; close v_codes;
note equality of numbers of rows being returned procs you. if number of rows greater number of codes employees won't inserted temp_table.
Comments
Post a Comment