I'm using Xmltable to convert a field of comma-delimited email addresses to a table of values.
WITH
data AS
  (
    select  1 ID, 'foo&bar@domain.tld,bar@domain.tld' recipients from dual
  )
select  ID, trim(COLUMN_VALUE) recipient
from    data,xmltable(('"'|| REPLACE( recipients , ',', '","') || '"'))
produces an error:
[72000][19112] ORA-19112: error raised during evaluation: XVM-01003: [XPST0003] Syntax error at '"foo' 1 "foo&bar@domain.tld","bar@domain.tld" - ^
However, when I replace the & with its entity value (&):
WITH
DATA AS
  (
    select  1 ID, 'foo&bar@domain.tld,bar@domain.tld' recipients from dual
  )
select  ID
        -- & --> &
        , replace( trim(COLUMN_VALUE), '&', '&') recipient
from    data
        -- & --> &
        ,xmltable(('"'|| REPLACE( replace( recipients, '&','&')  , ',', '","') || '"'))
the query works:
ID,RECIPIENT
1,foo&bar@domain.tld
1,bar@domain.tld
I'm imaging that there might be other characters that are valid in an email address, but will be problematic for Xmltable.
Is there a better way to do this?
 
     
    