I working on one SP which will split data present in one of the input parameter to multiple rows and column and will insert the same into table.
Format of the that string will be <ID>-<Name>|<ID1>-<Name1>|<ID2>-<Name2> e.g. 145-Test.txt|236-Test1.png
Expected output of the the provided example will be as below
ID | Name
145 Test.txt
236 Test1.png
Using below query I am able to split data into rows on the basis of | separator
select REGEXP_SUBSTR('145-Test.txt|236-Test1.png','[^|]+', 1, level) from DUAL
connect by regexp_substr('145-Test.txt|236-Test1.png', '[^|]+', 1, level) is not null;
also using below query I am able to split string data into columns on the basis of - separator
select REGEXP_SUBSTR('145-Test.txt', '[^-]+', 1, 1) ID,
REGEXP_SUBSTR('145-Test.txt', '[^-]+', 1, 2) Name
FROM DUAL;
Need help to merge these two queries so that I can get the expected output from single query only.