How to use varchar2 variable in XMLTable function?

1.6k views Asked by At

I am trying to use XMLTable function as follow,

DECLARE IDs VARCHAR2(2000);

IDs := '4013105,4013106,4013107,4013108,4013109';

SELECT TO_NUMBER(COLUMN_VALUE) FROM XMLTABLE(:TRACT_IDS);

but getting this error

PL/SQL: ORA-19102: XQuery string literal expected

If I use XMLTable with following example it runs successfully,

SELECT TO_NUMBER(COLUMN_VALUE) FROM XMLTABLE('4013105,4013106,4013107,4013108,4013109');

Please help in this regard..

1

There are 1 answers

0
Wernfried Domscheit On

Do you like to do this?

DECLARE 
   IDs VARCHAR2(2000);
BEGIN
   IDs := '4013105,4013106,4013107,4013108,4013109';
   SELECT TO_NUMBER(COLUMN_VALUE) 
   BULK COLLECT INTO ...
   FROM XMLTABLE(IDs);
END;