Returning an Entire XML Column



Using DataDirect XQuery®, it's straightforward to return an entire XML column because it does not require evaluation of the contents of the column. For the HOLDINGSXML table, the following query returns a column:

collection('HOLDINGSXML')/HOLDINGSXML/XMLCOL

The result looks like this:

<XMLCOL>
	<HOLDINGS>
	 <SHARE COMPANY="Amazon.com, Inc." 
 USERID="Jonathan">3000</SHARE>
	 <SHARE COMPANY="eBay Inc." USERID="Jonathan">4000</SHARE>
	 <SHARE COMPANY="Int'l Business Machines C" 
 USERID="Jonathan">2500</SHARE>
	 <SHARE COMPANY="Progress Software"
 USERID="Jonathan">23</SHARE>
	</HOLDINGS>
</XMLCOL>
<XMLCOL>
	<HOLDINGS>
	 <SHARE COMPANY="Amazon.com, Inc." 
 USERID="Minollo">3000</SHARE>
	 <SHARE COMPANY="eBay Inc." USERID="Minollo">4000</SHARE>
	 <SHARE COMPANY="Lucent Technologies Inc." 
 USERID="Minollo">40000</SHARE>
	 <SHARE COMPANY="Progress Software" 
 USERID="Minollo">4000000</SHARE>
	</HOLDINGS>
</XMLCOL>

In contrast, any query that evaluates path expressions against the contents of an XML column fails. For example, the following query fails and raises an error:

collection('HOLDINGSXML')/HOLDINGSXML/XMLCOL/HOLDINGS

Because the // operator requires all descendant nodes to be evaluated, this operation fails if applied to an XML column. For example, the following query fails and raises an error:

collection('HOLDINGSXML')//HOLDINGSXML