Solved

Spool file xml query from Oracle

Posted on 2014-09-30
6
828 Views
Last Modified: 2014-09-30
Greeting,

I use sqlplus to spool xml query but somewhere in the xml, the entries wrap to the second line like the following.

<DESCRIPTION>FORMERLY - xxxxxxxxxx &amp; LLLLLLLLLLLLLLLLL OFFICE BUILDING</DES
CRIPTION>

Below is what I ran. How to fix it?

set linesize 9000;
set trimspool on;
set pages 0;
set feedback off;


spool C:\DATA.xml;
select dbms_xmlgen.getxml('MyQuery here') xml from dual;
spool off;
0
Comment
Question by:mrong
  • 3
  • 3
6 Comments
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40352637
Try this:
select xmlserialize(document xmltype(dbms_xmlgen.getxml('MyQuery here')) version '1.0' indent) from dual;
0
 

Author Comment

by:mrong
ID: 40352666
select xmlserialize(document xmltype(dbms_xmlgen.getxml('select id from mytable')) version '1.0' indent) from dual
                                                                                                        *
ERROR at line 1:
ORA-00907: missing right parenthesis
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40352682
What version of Oracle are you on(include all 4 numbers)?

I tested it on 11.2.0.2.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:mrong
ID: 40352688
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
0
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 40352717
For 10g try:

select xmltype(dbms_xmlgen.getxml('select id from mytable')).extract('/*') from dual;
0
 

Author Closing Comment

by:mrong
ID: 40352734
Thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now