on 2009 Nov 27 3:01 PM
Is there any easy way of unloading data from an Sql Anywhere 10 database table as XML?
Just a quick and short answer - There are several ways to unload as XML - among others
It's well documented in the SA 10 docs: SQL Anywhere® Server - SQL Usage > Using XML in the Database
One easy way to select a whole table might be to use
SELECT * FROM MyTable ORDER BY MyPkColumn
FOR XML AUTO;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you want elements rather than attributes then try:
select * from Category for xml auto, elements
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I took a short look at the OUTPUT TO ... FORMAT XML clause. I didn't fund the generated xml very useful. For example, if i have a Categories table with this structure:
CategoryId (PK), Name, Description
I was expecting something like
<root>
<Category>
<CategoryId>1</CategoryId>
<Name>Sports</name>
<Description>All sports items</Description>
</Category>
<Category>
...
</Category>
</root>
The xml generated does look complicated:
<row>
<column name="CategoryId">...</column>
<column name="Name">...</column>
<column name="Description">...</column>
<row>
Anyways, thanks. I'll dig a bit deeper.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sergio, then the suggestions with SELECT ... FOR XML AUTO, ELEMENTS should fit, as a quick test with "SELECT * FROM sysdomain FOR XML AUTO, elements;" shows.
In order to get a root, you might have to use wrap your select in a SELECT XMLELEMENT( NAME root, (<yourselecthere> ));
User | Count |
---|---|
68 | |
8 | |
8 | |
6 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.