Hi all,
I have the following query which gives me a HTML output through the query. Please make sure to run the query in the HR schema.
SELECT '<thead>
<tr>
<td>Country Id</td>
<td>Country Name</td>
<td style="width: 40px"></td>
</tr>
</thead>
<tbody>'||RTRIM(XMLAGG(XMLELEMENT(E,"TableData",',').EXTRACT('//text()')).GetClobVal(),',')||CHR(13)||'</tbody>'
FROM (SELECT '<tr>
<td>'||A.COUNTRY_ID||'</td>
<td>'||A.COUNTRY_NAME||'</td>
</tr>' AS "TableData"
FROM COUNTRIES A
WHERE A.REGION_ID = :REGION_ID)DUAL;
Pass the REGION_ID as 1,2,3, or 4.
The output of this query is as follows.
<thead>
<tr>
<td>Country Id</td>
<td>Country Name</td>
<td style="width: 40px"></td>
</tr>
</thead>
<tbody><tr>
<td>AR</td>
<td>Argentina</td>
</tr>,<tr>
<td>BR</td>
<td>Brazil</td>
</tr>,<tr>
<td>CA</td>
<td>Canada</td>
</tr>,<tr>
<td>MX</td>
<td>Mexico</td>
</tr>,<tr>
<td>US</td>
<td>United States of America</td>
</tr>
</tbody>
I need to remove these '<' signs which should be '<', '>' should be '>'. The whole query output should be in the expected format. Please let me know how to do it using the XMLAGG method as I have a big set of data to be aggregated which cannot be implemented using LISTAGG or WM_CONCAT.
Thanks.