Contents Index XML and Adaptive Server Anywhere Exporting relational data as XML

ASA SQL User's Guide
  Using XML in the Database

Storing XML documents in relational databases


Adaptive Server Anywhere supports two data types that can be used to store XML documents in your database: the XML data type and the LONG VARCHAR data type. Both of these data types store the XML document as a string in the database.

Benefits of using the XML data type 

You can cast between the XML data type and any other data type that can be cast to or from a string. Note that there is no checking that the string is well-formed when it is cast to XML.

When you generate elements from relational data, any characters that are invalid in XML are quoted unless the data is of type XML. For example, suppose you wish to generate a <product> element with the following content:

<hat>

so that the element content contains less than and greater than signs. If you write a query that specifies that element content is of type XML, as follows:

SELECT XMLFOREST( CAST( '<hat>' AS XML ) AS product )

then the greater than and less than signs are not quoted and you get the following result:

<x><y/></x>

However, if the query does not specify that element content is of type XML, for example:

SELECT XMLFOREST( '<hat>' AS product )

then the less than and greater than signs are quoted as follows:

<x>&lt;y/&gt;</x>

Note that attribute content is always quoted, regardless of the data type.

For more information about how element content is quoted, see Invalid column names.

For more information about the XML data type, see XML data type [Character].


Contents Index XML and Adaptive Server Anywhere Exporting relational data as XML