XMLTABLE to split string
SELECT ROWNUM,
       TRIM(column_value) ref_string
FROM   XMLTABLE(('"'||REPLACE('AAA,BBB,CCC',',','","')||'"')) 
;

-- To get data in a specific order ROW_NUMBER() can be used

SELECT  row_num, ref_string
FROM (SELECT
       ref_string,
       ROW_NUMBER() OVER (PARTITION BY 1 ORDER BY 1 ASC) as row_num
      FROM (SELECT TRIM(column_value) ref_string
            FROM   XMLTABLE(('"'||REPLACE('AAA,BBB,CCC',',','","')||'"')) 
           )
     )
;

-- To get specific element in the output - first element [AAA]

SELECT  ref_string
FROM (SELECT
       ref_string
       ,ROW_NUMBER() OVER (PARTITION BY 1 ORDER BY 1 ASC) as row_num
      FROM (SELECT TRIM(column_value) ref_string
            FROM   XMLTABLE(('"'||REPLACE('AAA,BBB,CCC',',','","')||'"'))
           )
     )
WHERE row_num =1
;


   XML Functions    XMLSEQUENCE - String Splitting

   ROW_NUMBER(), RANK()

Oracle registered trademark of Oracle Corporation.

Last Revised On: August 31st, 2014

  3096