Prøv disse metoder.
Dette får det første element, som du oprindeligt bad om:
SQL> with tbl(str) as (
select 'Hello My Delimiter World' from dual
)
SELECT REGEXP_SUBSTR( str ,'(.*?)( My Delimiter |$)', 1, 1, NULL, 1 ) AS element
FROM tbl;
ELEME
-----
Hello
Denne version analyserer hele strengen. NULL-elementer tilføjet for at vise, at det fungerer med manglende elementer:
SQL> with tbl(str) as (
select ' My Delimiter Hello My Delimiter World My Delimiter My Delimiter test My Delimiter ' from dual
)
SELECT LEVEL AS element,
REGEXP_SUBSTR( str ,'(.*?)( My Delimiter |$)', 1, LEVEL, NULL, 1 ) AS element_value
FROM tbl
CONNECT BY LEVEL <= regexp_count(str, ' My Delimiter ')+1;
ELEMENT ELEMENT_VALUE
---------- --------------------
1
2 Hello
3 World
4
5 test
6
6 rows selected.