I used the following command.
select col1, col2, XMLAGG(XMLELEMENT(E, colname || \',\')).EXTRACT(\'//text()\') from ta