DB2 Version 9.7 for Linux, UNIX, and Windows

pureXML - Application Development samples

These samples demonstrate XML support for application development features such as insert, update, and delete, XML parsing, validation, and serialization, hybrid use of SQL/XML, XML data type support in SQL and external stored procedures, XML decomposition, SQL/XML publishing functions.

These samples are available in various programming languages and can be found in the language specific sub-directories in the following location:
  • On Windows: %DB2PATH%\sqllib\samples\xml (where %DB2PATH% is a variable that determines where DB2® database server is installed)
  • On UNIX: $HOME/sqllib/samples/xml (where $HOME is the home directory of the instance owner)
Table 1. pureXML - Application development samples
Samples by language Sample program name Program description
CLI xmlinsert.c Insert an XML document into a column of XML datatype.
  xmlupdel.c Update and delete XML documents in the tables.
  xmlread.c Read XML data stored in tables.
  reltoxmldoc.c Create an XML document directly from data stored in relational tables using various SQL/XML publishing functions.
  xmltotable.c Insert the data from an XML document into relational tables using SQL/XML functions like XMLTABLE, XMLQUERY and the XMLEXISTS predicate.
  simple_xmlproc.c Simple stored procedure with XML type parameters.
  simple_xmlproc_client.c Client program to call the routine in simple_xmlproc.c.
  simple_xmlproc_create.db2 CLP script to register the stored procedure in simple_xmlproc.c
  simple_xmlproc_drop.db2 CLP script to drop the stored procedure in simple_xmlproc.c
C xmlinsert.sqc Insert an XML document into a column of XML datatype.
  xmludfs.sqc Pass the XML data type as an input parameter, declare XML data type local variables, and return values when using scalar functions, sourced functions, SQL-bodied UDFs and table UDFs.
  xmludfs.c Pass the XML data type as an input parameter, declare XML data type local variables, and return values when using scalar functions, sourced functions, SQL-bodied UDFs and table UDFs.
  xmlupdel.sqc Update and delete XML documents in the tables.
  xmlread.sqc Read XML data stored in tables.
  reltoxmltype.sqc Create an XML object from data stored in relational tables using various SQL/XML publishing functions.
  xmldecomposition.sqc Decompose data stored in an XML file and insert the data into tables. Specify the order of insertion to be used during XML document shredding.
  recxmldecomp.sqc Register a recursive XML schema to the XSR and enable it for decomposition.
  simple_xmlproc.sqc Simple stored procedure with XML type parameters.
  simple_xmlproc_client.db2 CLP script to call the routine in simple_xmlproc.sqc
  simple_xmlproc_create.db2 CLP script to register the stored procedure in simple_xmlproc.sqc
  simple_xmlproc_drop.db2 CLP script to drop the stored procedure in simple_xmlproc.sqc
  xmltrig.sqc Use the trigger processing capability for enforced automatic validation of incoming XML documents.
  xmlintegrate.sqc Use the XMLROW and XMLGROUP functions for mapping relational data to XML. Demonstrate XMLQuery default passing mechanism and the default column specification for XMLTABLE.
  xmlcheckconstraint.sqc Create tables with check constraints on an XML column using IS VALIDATED and IS NOT VALIDATED predicates and specify one or more schemas using the ACCORDING TO XMLSCHEMA clause.
  xmlxslt.sqc Use the XSLTRANSFORM function to convert XML documents residing in the database into HTML, plain text, or other forms of XML using style sheets.
CLP xmlinsert.db2 Insert an XML document into a column of XML datatype.
  xrpart.db2 Use of XML in range partitioned tables and support for local and global indexes.
  xmlpartition.db2 Use of XML in partitioned database environment, MDC and range partitioned tables.
  xmlmdc.db2 Moves data from MDC to non-MDC tables and use of block indexes, global indexes, and faster insertion and deletion.
  xmludfs.db2 Pass the XML data type as an input parameter, and return values when using scalar functions, sourced functions, SQL-bodied UDFs and table UDFs.
  xmldbafn.db2 Use of inline DBA functions to determine the estimated inline length for XML documents.
  xmlolic.db2 Reorganizes the indexes defined on a table and how to reorganize nonpartitioned indexes on a range-partitioned table.
  xmlindgtt.db2 Use of declared global temporary tables with the XML data type.
  xmlupdel.db2 Update and delete XML documents in the tables.
  reltoxmldoc.db2 Create an XML document directly from data stored in relational tables using various SQL/XML publishing functions.
  reltoxmltype.db2 Create an XML object from data stored in relational tables using various SQL/XML publishing functions.
  xmldecomposition.db2 Decompose data stored in an XML file and insert the data into tables. Specify the order of insertion to be used during XML document shredding.
  recxmldecomp.db2 Register a recursive XML schema to the XSR and enable it for decomposition.
  simple_xmlproc.db2 Simple stored procedure with XML type parameters
  xmltotable.db2 Insert the data from an XML document into relational tables using SQL/XML functions like XMLTABLE, XMLQUERY and the XMLEXISTS predicate.
  xmltrig.db2 Use the trigger processing capability for enforced automatic validation of incoming XML documents.
  xmlintegrate.db2 Use the XMLROW and XMLGROUP functions for mapping relational data to XML. Demonstrate XMLQuery default passing mechanism and the default column specification for XMLTABLE..
  xmlcheckconstraint.db2 Create tables with check constraints on an XML column using IS VALIDATED and IS NOT VALIDATED predicates and specify one or more schemas using the ACCORDING TO XMLSCHEMA clause.
  xmlxslt.db2 Use the XSLTRANSFORM function to convert XML documents residing in the database into HTML, plain text, or other forms of XML using style sheets.
JDBC XmlInsert.java Insert an XML document into a column of XML datatype.
  XmlMdc.java Moves data from MDC to non-MDC tables and use of block indexes, global indexes, and faster insertion and deletion.
  XmlUdfs.java Pass the XML data type as an input parameter, and return values when using scalar functions, sourced functions, SQL-bodied UDFs and table UDFs.
  XmlUpDel.java Update and delete XML documents in the tables.
  XmlRead.java Read XML data stored in tables.
  RelToXmlDoc.java Create an XML document directly from data stored in relational tables using SQL/XML publishing functions.
  RelToXmlType.java Create an XML object from data stored in relational tables using various SQL/XML publishing functions.
  XmlDecomposition.java Decompose data stored in an XML file and insert the data into tables. Specify the order of insertion to be used during XML document shredding.
  RecXmlDecomp.java Register a recursive XML schema to the XSR and enable it for decomposition.
  Simple_XmlProc.java Simple stored procedure with XML type parameters.
  Simple_XmlProc_Client.java Client program to call the routine in Simple_XmlProc.java.
  Simple_XmlProc_Create.db2 CLP script to register the stored procedure in Simple_XmlProc.java
  Simple_XmlProc_Drop.db2 CLP script to drop the stored procedure in Simple_XmlProc.java
  XmlToTable.java Insert the data from an XML document into relational tables using SQL/XML functions like XMLTABLE, XMLQUERY and the XMLEXISTS predicate.
  XmlTrig.java Use the trigger processing capability for enforced automatic validation of incoming XML documents.
  XmlCheckConstraint.java Create tables with check constraints on an XML column using IS VALIDATED and IS NOT VALIDATED predicates and specify one or more schemas using the ACCORDING TO XMLSCHEMA clause.
SQLJ XmlInsert.sqlj Insert an XML document into a column of XML datatype.
  XmlUpDel.sqlj Update and delete XML documents in the tables.
  XmlRead.sqlj Read XML data stored in tables.
  RelToXmlDoc.sqlj Create an XML document directly from data stored in relational tables using SQL/XML publishing functions.
  RelToXmlType.sqlj Create an XML object from data stored in relational tables using SQL/XML publishing functions.
  XmlToTable.sqlj Insert the data from an XML document into relational tables using SQL/XML functions like XMLTABLE, XMLQUERY and the XMLEXISTS predicate.
  XmlIntegrate.sqlj Use the XMLROW and XMLGROUP functions for mapping relational data to XML. Demonstrate XMLQuery default passing mechanism and the default column specification for XMLTABLE..
  XmlXslt.sqlj Use the XSLTRANSFORM function to convert XML documents residing in the database into HTML, plain text, or other forms of XML using style sheets.
PHP XmlFlwor_DB2.php Use the XQuery FLWOR expression.
  XmlIndex_DB2.php Create an index and use it in an XQuery.
  XmlInsert_DB2.php Insert an XML document into a column of XML data type.
  XmlRead_DB2.php Read XML data stored in tables.
  XmlRelToXmlDOC_DB2.php Create XML document directly from data stored in relational tables using SQL/XML publishing functions.
  XmlRelToXmlType_DB2.php Create an XML document from relational and XML data using SQL/XML publishing functions.
  XmlRunstats_DB2.php Perform RUNSTATS on a table containing XML type columns..
  XmlSchema_DB2.php Register the XML schema to the database and use the registered schema to validate and insert XML documents.
  XmlSQLXQuery_DB2.php Use SQL/XML queries.
  XmlUniqueIndexes_DB2.php Create an index with UNIQUE and VARCHAR length constraints.
  XmlUpAndDel_DB2.php Update and delete XML documents in the tables.
  XmlToTable_DB2.php Insert the data from an XML document into relational tables using SQL/XML.
  XmlXPath_DB2.php Run simple XPath queries.
  XmlXQuery_DB2.php Execute nested XQuery FLWOR expressions.