Encoding considerations for retrieval of XML data from a Db2 table

When you retrieve XML data from a Db2 table, you need to avoid data loss and truncation.

Data loss can occur when characters in the source data cannot be represented in the encoding of the target data. Truncation can occur when:
  • Conversion to the target data type results in expansion of the data.
  • The application host variable length is not set or is set too small.

    Because DESCRIBE does not return a length for XML columns, applications that use an SQLDA must set a length in the SQLDA that reflects the amount of application storage available for each application variable. Applications can provide enough storage to hold the largest retrieved documents, or use FETCH CONTINUE to retrieve large XML documents in pieces.

Data loss is less of a problem for Java™ applications than for other types of applications because Java string data types use Unicode UTF-16 or UCS2 encoding. Truncation is possible because expansion can occur when UTF-8 characters are converted to UTF-16 or UCS-2 encoding.