Examples of Character Data in a CASE Expression: Example 2 - Teradata Vantage - Analytics Database

SQL Functions, Expressions, and Predicates

Deployment
VantageCloud
VantageCore
Edition
VMware
Enterprise
IntelliFlex
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2025-03-30
dita:mapPath
obm1628111499646.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
kby1472250656485
lifecycle
latest
Product Category
Teradata Vantageā„¢

The result of the following query is a 5354 failure (Arguments must be of type KANJI1) because one THEN/ELSE expression is a KANJI1 literal, but the server character sets of all the other THEN/ELSE expressions are not KANJI1.

   SELECT i, CASE
               WHEN i=1 THEN column_l
               WHEN i=2 THEN column_u
               WHEN i=3 THEN column_j
               WHEN i=4 THEN column_g
               WHEN i=5 THEN _Kanji1'4142'XC
               ELSE column_k
             END
   FROM table_1
   ORDER BY 1;

For this example, assume the following table definition:

   CREATE table_1
     (i        INTEGER,
      column_l CHARACTER(10) CHARACTER SET LATIN,
      column_u CHARACTER(10) CHARACTER SET UNICODE,
      column_j CHARACTER(10) CHARACTER SET KANJISJIS,
      column_g CHARACTER(10) CHARACTER SET GRAPHIC,
      column_k CHARACTER(10) CHARACTER SET KANJI1);

The following query fails because the server character set is GRAPHIC (because the server character set of the first THEN with a character type is GRAPHIC):

   SELECT i, CASE
               WHEN i=1 THEN 4
               WHEN i=2 THEN column_g
               WHEN i=3 THEN 5
               WHEN i=4 THEN column_l
               WHEN i=5 THEN column_k
               ELSE 10
             END
   FROM table_1
   ORDER BY 1;