THEN/ELSE Character Type Expressions - Analytics Database - Teradata Vantage

SQL Functions, Expressions, and Predicates

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-01-12
dita:mapPath
obm1628111499646.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
kby1472250656485
lifecycle
latest
Product Category
Teradata Vantageā„¢

The following rules apply to CASE expressions where the data types of all of the THEN/ELSE expressions are character:

  • The result of the CASE expression is also a character data type, with the length equal to the maximum length of the different character data types of the THEN/ELSE expressions.
  • If the data types of all of the THEN/ELSE expressions are CHARACTER (or CHAR), the result data type is CHARACTER. If one or more expressions are VARCHAR (or LONG VARCHAR), the result data type is VARCHAR.
  • The server character set of the result is determined as follows:
    • If the CASE expression contains 1 nonliteral character expression and 1 or more literals, then Vantage tries to translate every literal to the character set of the nonliteral. If the translations are successful, then the character set of the nonliteral is used for the result data type. If the translations are not successful, the server character set of the result is Unicode.
    • If the CASE expression contains more than 1 nonliteral character expression and 1 or more literals, then:

      If all of the nonliteral expressions have the same character set, then Vantage uses this character set as the common data type. Otherwise, if the nonliteral expressions have differing character sets, then Vantage uses the Unicode character set as the common data type.

      Vantage tries to translate every literal to the character set of the common data type. If the translations are successful, then the result data type has the character set of the common data type. If the translations are not successful, the server character set of the result is Unicode.