Manipulating XML data - examples
After you create a nickname, you can query and manipulate XML data in the remote table or XML document on the federated system. The federated system supports all of the data manipulation operations for XML data that the database system supports.
The following examples show the different methods that you can use to work with XML data by using the nickname NNXML1.
Manipulating XML data with SQL
With SQL you can perform basic select, insert, update, and delete operations.
Example: Use the SELECT and INSERT statements to access and insert XML data from the nickname NNXML1.
SELECT xmlcol FROM NNXML1;
INSERT INTO NNXML1 (xmlcol) VALUES ('<a><b>My data</b></a>');
Manipulating XML data with SQL/XML functions
With SQL/XML functions, you can perform a range of operations that include querying, validating, and publishing XML data.
Example: Use the XMLVALIDATE function to validate XML data by using the XML schema that is obtained from the schema specification in the XML instance document:
SELECT XMLVALIDATE(xmlcol)FROM NNXML1;
Manipulating XML data with XQuery
You can use XQuery functions to manipulate XML data, such as the xmlcolumn function.
Example: Use XQuery to retrieve element b, which is a child of root a, from the XML column named XMLCOL:
xquery db2-fn:xmlcolumn('NNXML1.XMLCOL')/a/b;