简体   繁体   中英

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;

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM