0

Here is my example string:

select 'po1,qty1,po2,qty2,..,POn,QTYn' str from dual.

The string length is dynamic. It may have more than one PO and QTY.

Now, I want the output displayed as all the POs in first column and quantities in second column.

0
1
select
  regexp_substr(pq, '[^,]+', 1, 1) as po,
  regexp_substr(pq, '[^,]+', 1, 2) as qty
from
(
  select
    regexp_substr('po1,qty1,po2,qty2','[^,]+,[^,]+', 1, level) as pq
  from dual
    connect by regexp_substr('po1,qty1,po2,qty2','[^,]+,[^,]+', 1, level) is not null
);


PO         QTY
---------- ----------
po1        qty1
po2        qty2
0

From the first Google Result, you'd want something like

SELECT regexp_substr('po1,qty1,po2,qty2','[^,]+', 1, level) from dual

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.