0

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;
1
  • Does what you want is just to aggregate all the row results to one big XML with one root element, instead of multiple rows with one element in each? Commented Apr 7, 2014 at 16:50

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Evenro, Thanks for the link. I even tried using xmlagg but when i execute, the result just shows XMLTYPE nothing else. I am executing in sql developer. I want the result like <tr><td>SYSTEM</td><td>C:\APP****\ORADATA\ORCL\SYSTEM01.DBF</td><td>740</td><td>2010-04-02</td><td>94720</td> in text datatype so that i can save it in a variable and attach the variable.
double click the "XMLTYPE" to see the content in this interface... the "XMLTYPE" is a marker that there is a lob in the background that hold your content... :)
(Remember that XMLType is not a string, therefore - viewing it would require a different viewer)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.