XML Data Type Values and Conversions - ODBC Driver for Teradata

ODBC Driver for Teradata User Guide

Product
ODBC Driver for Teradata
Release Number
15.10
Language
English (United States)
Last Update
2018-10-07
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.

Note: 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.

 

Table 50: 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.

 

Table 51: 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” on page 121.

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.