One option is regexp_substr()
. Here is one approach that takes in account the possibility of empty slots in the delimited string:
select
regexp_substr(col, '([^|]*)(\||$)', 1, 1, null, 1) col1,
regexp_substr(col, '([^|]*)(\||$)', 1, 2, null, 1) col2,
regexp_substr(col, '([^|]*)(\||$)', 1, 3, null, 1) col3,
regexp_substr(col, '([^|]*)(\||$)', 1, 4, null, 1) col4,
regexp_substr(col, '([^|]*)(\||$)', 1, 5, null, 1) col5,
regexp_substr(col, '([^|]*)(\||$)', 1, 6, null, 1) col6,
regexp_substr(col, '([^|]*)(\||$)', 1, 7, null, 1) col7
from mytable
Demo on DB Fiddle:
with mytable as (select 'MERGE|WorkRelationship|||2020/12/31|RESIGNATION|Y||XYZ Limited|12345A' col from dual)
select
regexp_substr(col, '([^|]*)(\||$)', 1, 1, '', 1) col1,
regexp_substr(col, '([^|]*)(\||$)', 1, 2, '', 1) col2,
regexp_substr(col, '([^|]*)(\||$)', 1, 3, '', 1) col3,
regexp_substr(col, '([^|]*)(\||$)', 1, 4, '', 1) col4,
regexp_substr(col, '([^|]*)(\||$)', 1, 5, '', 1) col5,
regexp_substr(col, '([^|]*)(\||$)', 1, 6, '', 1) col6,
regexp_substr(col, '([^|]*)(\||$)', 1, 7, '', 1) col7
from mytable
COL1 | COL2 | COL3 | COL4 | COL5 | COL6 | COL7
:---- | :--------------- | :--- | :--- | :--------- | :---------- | :---
MERGE | WorkRelationship | null | null | 2020/12/31 | RESIGNATION | Y