XML Data Type Values and Conversions - ODBC Driver for Teradata

ODBC Driver for Teradata User Guide

Product
ODBC Driver for Teradata
Release Number
16.10
Published
May 2017
Language
English (United States)
Last Update
2018-07-11
dita:mapPath
smj1488824663219.ditamap
dita:ditavalPath
Audience_PDF_product_legacy_odbc_include.ditaval
dita:id
B035-2526
lifecycle
previous
Product Category
Teradata Tools and Utilities

The ODBC driver supports conversions of XML values to and from both ODBC Character C types (SQL_C_CHAR and SQL_C_WCHAR) and the Binary C type SQL_C_BINARY.

XML data type values retrieved from the database may be complete XML documents, but also non-well-formed text entities, including XML document fragments, such as sequences or atomic values. XML data type values inserted into the database must be XML documents (well-formed).

The recommended conversion of XML is to or from SQL_C_BINARY or SQL_C_WCHAR because it eliminates conversion to a non-Unicode code page used by the application, which can result in conversion errors. The default ODBC C type for SQL_TD_XML is SQL_C_BINARY.

SQL_TD_XML values represented as ODBC C types
XML represented as Description
SQL_C_BINARY The value is a sequence of characters encoded in UTF-8 regardless of any encoding declaration in the XML text.
SQL_C_CHAR The value is a sequence of characters encoded in the application code page regardless of any encoding declaration in the XML text.
SQL_C_WCHAR The value is a sequence of characters encoded in the Unicode encoding in effect for the application (UTF-8 or UTF-16 for Linux/Unix. UTF-16 for Windows, UTF-32 for Apple OS X). The encoding is independent of any encoding declaration in the XML text.

For a given XML document the recommended ODBC C type for working with the document in ODBC depends on the XML document encoding as determined by the XML declaration in the document.

Recommended ODBC C Type for XML Document Encoding
XML Document Encoding Declaration Recommended ODBC C type for working with the document in an ODBC application
Windows Linux/Unix Apple OS X
UTF-8 SQL_C_BINARY or SQL_C_WCHAR. Note that when using SQL_C_WCHAR the encoding will be UTF-16 SQL_C_BINARY or SQL_C_WCHAR. SQL_C_BINARY or SQL_C_WCHAR
UTF-16 SQL_C_WCHAR SQL_C_WCHAR with UTF-16 Unicode encoding as described in Unicode Character Types. SQL_C_WCHAR
Other SQL_C_CHAR using application code page matching document encoding SQL_C_CHAR using an application code page matching the XML document encoding. SAL_C_CHAR with locale LC_TYPE setting matching the document encoding.