XML Value Encoding and the Encoding Declaration - Advanced SQL Engine - Teradata Database

XML Data Type

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-22
dita:mapPath
amr1556233250442.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1140
lifecycle
previous
Product Category
Teradata Vantage™

This table shows what the encoding and encoding declaration will be based on the return data type of the XML value.

Return Type of XML Value Encoding Encoding Declaration
XML type 
(in record/indicator mode) UTF-8
  • If a document is retrieved in its entirety, and if it originally had an encoding declaration, the encoding declaration is preserved.
  • If there was no original encoding declaration, none is added (no encoding declaration is interpreted as UTF-8 by the parser according to the standard).
CLOB or VARCHAR
(in field mode, or when XMLSERIALIZE is called with CLOB or VARCHAR target type) The encoding of the document received will match the session character set in use.
  • If a document is retrieved in its entirety, and if it originally had an encoding declaration, the encoding declaration is preserved.
  • If there was no original encoding declaration, none is added.
BLOB or VARBYTE 
(when XMLSERIALIZE is called with BLOB or VARBYTE target type) The encoding of the XML value will be as specified by the user via the ENCODING clause in the XMLSERIALIZE function call. It is UTF-8 if an encoding is not specified. The encoding declaration is as specified by user via the ENCODING clause or none.

If the XML values are returned as XML, CLOB, or VARCHAR values, there is potential for mismatch between the actual encoding of the XML value and its encoding declaration. You can instruct the parser via parser-provided APIs to override the encoding declaration in the XML document based on external knowledge, such as knowing the session character set in use.