17.10 - Example: Using STRING_CS to Translate a KANJI1 String to UNICODE - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Functions, Expressions, and Predicates

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-28
dita:mapPath
SQL_Functions__Expressions__and_Predicates.Upload_071421/djk1612415574830.ditamap
dita:ditavalPath
SQL_Functions__Expressions__and_Predicates.Upload_071421/wrg1590696035526.ditaval
dita:id
kby1472250656485

Consider the SysNames table from the preceding example, “Example: Using STRING_CS to Determine the Client Character Set.”

The following statement uses STRING_CS to determine which encoding to use to translate strings in the SysName column from the KANJI1 server character set to the UNICODE server character set:

   SELECT CASE STRING_CS(SysName)
      WHEN 0 THEN TRANSLATE(SysName USING KANJI1_SBC_TO_UNICODE)
      WHEN 1 THEN TRANSLATE(SysName USING KANJI1_KANJIEBCDIC_TO_UNICODE)
      WHEN 2 THEN TRANSLATE(SysName USING KANJI1_KANJIEUC_TO_UNICODE)
      WHEN 3 THEN TRANSLATE(SysName USING KANJI1_KANJISJIS_TO_UNICODE)
      ELSE TRANSLATE(SysName USING KANJI1_SBC_TO_UNICODE)
      END
   FROM SysNames;