user3311382
user3311382

Reputation: 41

table results to xml in oracle

Experts, I want to send some results via email in the form of table, for which i need to convert the results into xml format. I want to store the results in a variable and attach to the xml body. The xml result gives me in the form of rows and i am unable to capture the xml results in a single row and convert that into varchar2 so that i can attach the variable. Need help... I am using Oracle Sql Developer 11g.

Below is the script i am using

select (XMLElement("tr"
,XMLFOREST(d.tablespace_name as "td", 
 d.file_name as "td",   d.bytes/1024/1024 as "td", 
 h.CREATION_TIME as "td",
 d.blocks as "td")))
from dba_data_files d
inner join v$datafile_header h
on d.TABLESPACE_NAME = h.TABLESPACE_NAME
order by d.TABLESPACE_NAME;

Upvotes: 0

Views: 161

Answers (1)

evenro
evenro

Reputation: 2646

If I understood the question correctly - please have a look at XMLAGG: http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions215.htm

This function allows creating one xml from multiple records.

Upvotes: 1

Related Questions