15.10 - String Delimiters - Preprocessor2 for Embedded SQL

Teradata Preprocessor2 for Embedded SQL Programmer Guide

prodname
Preprocessor2 for Embedded SQL
vrm_release
15.10
category
Programming Reference
featnum
B035-2446-035K

The APOST/QUOTE and APOSTSQL/QUOTESQL options control C string recognition and generation; the only values permitted in C are QUOTE and APOSTSQL.

QUOTE indicates that native C strings are enclosed by quotation marks (“).

APOSTSQL indicates that apostrophes (’) delimit the strings embedded within a SQL statement and quotation marks (") are used for the escape character.

See Chapter 2: “Connecting to the Database and Invoking PP2” for details on the use of these options.

In the following example, the source is an application that uses the QUOTE/APOSTSQL options. The resulting code that PP2 generates is:

EXEC SQL
      DECLARE cursor CURSOR FOR
         ’SELECT * FROM table
         WHERE COL1 = ’’ABCD’’;
      UPDATE “table one” SET COL2 = ’’ABCD’’’;

Delimited Identifiers and Character String Literals

Teradata SQL for Teradata Database 12.00 and later extends ANSI‑compliant Unicode® delimited identifiers and character string literals. This enables the Data Dictionary to function the same, whether or not Japanese character set support is enabled or not. Additionally, object names with multi‑byte character sets can be shared between sessions that have non‑Japanese character sets.

The Unicode delimited identifier is U&" ". The Unicode character string literal is U&' '. These new identifiers and literals are produced where ' 'XN and ' 'XC notation is used.

For example, prior to Teradata Database 12.00, the syntax to represent a Kanji string was:

SELECT * FROM '8273826082618250'XN; 
/* This hexadecimal string represents the Kanji1 string using the KANJIEUC_0U character set*/

For Teradata Database 12.00 and later, the syntax is:

SELECT * FROM U&"\FF34\FF21\FF22\FF11"; 
/* for post V2R12.0.0 Unicode Data Dictionary, the internal hex is based on UNICODE hex for object name   */

In the above example, backslash (\) is the escape character. The default escape character depends on the session charset, but will be backslash (\) or yen sign for all supported character sets. The above SQL can also be written as:

SELECT * FROM U&"$FF34$FF21$FF22$FF11" UESCAPE('$');

where $ is the escape character.