Start of change

SQL statements and SQL/XML functions

Many SQL statements support the XML data type. This enables you to perform many common database operations with XML data, such as creating tables with XML columns, adding XML columns to existing tables, creating triggers on tables with XML columns, and inserting, updating, or deleting XML documents. A set of SQL/XML functions, expressions, and specifications supported by DB2® database server takes full advantage of the XML data type.

XML data type

The XML data type can store an XML value up to 2 GB. A CCSID can be specified for the XML data type. If a CCSID is not specified, the value of the SQL_XML_DATA_CCSID QAQQINI option will be used. The default for this option is 1208 (UTF-8). The XML data type can store single byte and Unicode double byte characters.

A single row in a table that contains one or more XML or LOB values cannot exceed 3.5 GB. The XML data type can be specified in a partitioned table.

XML host variables and XML locators can be declared in application programs.

XML locators can be used to refer to XML values. An XML value can be fetched into an XML locator. An XML locator can be passed to a procedure or function. The locator can be specified as a value on an INSERT or UPDATE statement.

Journal entries for XML columns are the same as for LOBs. See "Journal entry layout of LOB columns" in the SQL programming topic collection.

Application development

Support for application development is provided by several programming languages, and through SQL and external functions and procedures:

Programming language support
Application development support of XML enables applications to combine XML and relational data access and storage. The following programming languages support the XML data type for SQL:
  • ILE RPG
  • ILE COBOL
  • C or C++ (embedded SQL or DB2 CLI)
  • Java™ (JDBC or SQLJ)
SQL and external functions and procedures
XML data can be passed to SQL procedures and external procedures by including parameters of data type XML in CREATE PROCEDURE parameter signatures. XML data can also be passed to SQL functions and external functions by including parameters of data type XML in CREATE FUNCTION parameter signatures. Existing SQL routine features support the implementation of procedural logic flow around SQL statements that produce or make use of XML values as well as the temporary storage of XML data values in variables.

Administration

The XML features provide a repository for managing the URI dependencies of XML documents:

XML schema repository (XSR)
The XML schema repository (XSR) is a repository for all XML artifacts required to process XML instance documents stored in XML columns. It stores XML schemas, referenced in XML documents. It can be used to validate or decompose XML instance documents.

Tooling

Support for the XML data type is available with the IBM® i Navigator.

Annotated XML schema decomposition

The XML features enable you to store and access XML data as XML documents. There can be cases where accessing XML data as relational data is required. Annotated XML schema decomposition decomposes documents based on annotations specified in an XML schema.

End of change