CHARSET(charset)
-cs charset - Teradata Preprocessor2

Teradata® Preprocessor2 for Embedded SQL Programmer Guide

Product
Teradata Preprocessor2
Release Number
17.00
Published
June 2020
Language
English (United States)
Last Update
2020-06-19
dita:mapPath
whb1544831946911.ditamap
dita:ditavalPath
obe1474387269547.ditaval
dita:id
B035-2446
lifecycle
previous
Product Category
Teradata Tools and Utilities

Purpose

Controls the mapping of data, object names and identifier values.

Usage Notes

CHARSET specifies the predefined character set name or character set code to be used at the following times:

Time Action Taken
Precompile The CHARSET option tells the precompiler the character set in which the input/output source files, the output listing, and output messages are written.
Runtime The precompiler establishes the character set for communicating with the database as the value of the CHARSET option unless overridden by the character set designated by the SET CHARSET request.

For information on SET CHARSET, see Teradata Vantage™ - SQL Stored Procedures and Embedded SQL , B035-1148 .

Subsequent connections to the database use the most recently established character set.

Specify the CHARSET option before the DATABASE or USERID operations if the DATABASE or USERID option values contain any Kanji or other multibyte character set characters.

CHARSET controls the mapping of data, object names and identifier values.

On IBM mainframe client platforms, if the CHARSET option is not specified, PP2 establishes the default character set by order of precedence:

  1. Character set specified in the HSHSPB parameter module.
  2. Default character set defined on the server specified by the TDPID option when SQLCHECK(FULL) is specified.
  3. EBCDIC

On network platforms, if the CHARSET option is not specified, PP2 establishes the default character set by order of precedence:

  1. The character set specified in the clispb.dat file
  2. ASCII

UTF-8 and UTF-16 Support

UTF-8 (Universal Transformation Format) and UTF-16 character sets are supported.

For details, see the tables in Supported Character Sets.

Use the SET CHARSET control statement with these character sets. For more information, see Teradata Vantage™ - SQL Stored Procedures and Embedded SQL , B035-1148 .

When using SET CHARSET for processing UTF-8 and UTF-16 data, precompile PP2 applications with one of these PP2 options:
  • CHARSET(EBCDIC) on mainframe systems
  • -cs ASCII on workstation-attached systems

Programming Considerations When Programming with UTF-8 and UTF-16 Character Sets

Object Names in Embedded SQL
When setting CHARSET to UTF-16 on workstation-attached systems or when setting CHARSET to UTF-8 and UTF-16 on mainframe systems, avoid problems with object names in embedded SQL by coding in the following ways:
  • Use only digits (0-9) and simple, single-byte Latin letters (A to Z, a to z).

    These characters always translate to the same internal representation, therefore they appear exactly the same in any session, regardless of the client system or the character set.

  • Do not use the hexadecimal representation to represent a character name.
Host Variables or Constants and Literals in Embedded SQL
When setting CHARSET to UTF-16 on workstation-attached systems or when setting CHARSET to UTF-8 and UTF-16 on mainframe systems:
  • Use host variables in the embedded SQL to supply UTF-8 and UTF-16 input values to, or receive UTF-8 and UTF-16 output values from, the database. Use host variables in the embedded SQL statements instead of UTF-8 and UTF-16 string constants.
  • Use only digits and simple, single byte Latin letters (A to Z, a to z) as constants in EXEC SQL statements. The constants must be in the same charset encoding as the SQL keywords.
When deciding the size of a character string, remember that storage for UTF-8 data is one to four bytes per character. Storage for UTF-16 data is two bytes per character.