Split multi column semicolon separated string and create records

前端 未结 2 646
心在旅途
心在旅途 2021-01-23 22:25

I have a stored procedure which receives three string parameters

1. p_ReqIDs VARCHAR2
2. p_ItemIDs VARCHAR2
3. p_Qtys    VARCHAR2

The above 3

2条回答
  •  再見小時候
    2021-01-23 22:33

    i did like this :) short and sweet.

    create or replace procedure proc1(p_ReqID varchar2,p_ItemID varchar2,p_ItemQty varchar2)
    is
    begin
     insert into test(req_id,item_id,itemqty)
     select regexp_substr(req_id,'[^;]+',1,level),
             regexp_substr(item_id,'[^;]+',1,level),
             regexp_substr(item_qty,'[^;]+',1,level)
      from  (
          select p_ReqID Req_ID,p_ItemID item_id,p_ItemQty item_qty
          from dual
          )
      connect by regexp_substr(req_id,'[^;]+',1,level) is not null;
    end;
    

提交回复
热议问题