我有一个函数返回/ p的多个我需要调用此函数插入​​表中

时间:2014-05-11 14:50:37

标签: plsql syntax-error

create or replace type branch_warehouse as object (wh_id number,wh_name varchar2(100));
create or replace type id_warehouse_list as table of branch_warehouse;

function get_ware_house_branch(p_BRANCH_IDS in out varchar2)
      return id_warehouse_list is
   l_warehouse_list id_warehouse_list := id_warehouse_list();
   str varchar2(300);
begin
   str := 'SELECT BRANCH_WAREHOUSE(w.wh_id, w.wh_name)
            FROM POD_WAREHOUSE_MASTER W
            where ( W.BRANCH_ID  IN  (' || p_BRANCH_IDS || '))';
   execute immediate str bulk collect into l_warehouse_list;
   for i in l_warehouse_list.first..l_warehouse_list.last loop 
      dbms_output.put_line(l_warehouse_list(i).wh_id || ', ' ||  l_warehouse_list(i).wh_name);
   end loop;
   return l_warehouse_list;
end;

procedure insert_place_warehouse_map(p_PLACE_NAME   in varchar2,
                                     p_BRANCH_IDS   in number,
                                     p_status       out varchar2,
                                     p_status_dtl   out varchar2) is
   v_ID number;
   l_warehouse_list id_warehouse_list := id_warehouse_list();
begin
   v_ID := get_place_id (p_PLACE_NAME);
   l_warehouse_list := get_ware_house_branch(p_BRANCH_IDS);
   for i in l_warehouse_list.first..l_warehouse_list.last loop
      insert into pod_place_warehouse_map(
         id, 
         place_id, 
         wh_id,        
         wh_name)
      values(
         pod_unique_val_seq.nextval, 
         v_ID,
         l_warehouse_list(i).wh_id,  
         l_warehouse_list(i).wh_name);
      v_rec_cnt    := sql%rowcount;
   end loop;    
   commit; 
   p_status     := 'SUCESS';
   p_status_dtl := v_rec_cnt||' Record Inserted Successfully';
exception
   when others then
      rollback;
      p_status_dtl := sqlcode||' - '||substr(sqlerrm,1,100);
      p_status     := 'ERROR'; 
end;

我在第二个代码中收到错误p_BRANCH_IDS cannot be used as assignment operator 第一个代码正在工作,
请帮忙

1 个答案:

答案 0 :(得分:1)

这是因为参数在第一个代码中声明为in out,但在第二个代码中声明为in