SQL/MX Programming Manual for Java
SQLJ Programming
HP NonStop SQL/MX Programming Manual for Java—523726-003
3-45
Character String Literals
Character String Literals
A character string literal is a series of characters enclosed in single quotes within an
SQL statement. Use a character string literal in an SQL statement anywhere you need
to supply a column value that has a character string data type.
Follow these guidelines when using character string literals in the SQL/MX statements
of an SQLJ program:
•
Using Special Characters in Character String Literals on page 3-45
•
Using Hexadecimal Values in Character String Literals on page 3-46
•
Specifying the Character Set Prefix on page 3-46
•
Specifying National Character String Literals on page 3-47
Using Special Characters in Character String Literals
To use special characters in character string literals, you must have a keyboard,
operating system, and input method editor (IME) that support a character set that
includes the special characters.
Use an IME to include, in the source code, character string literals that belong to a
particular character set outside the range of ASCII values. For example, Japanese
characters are part of the UCS2 character set. This statement inserts Japanese
characters in UCS2 format into an SQL/MX table named DEPT_INTERNATL:
The encoding of a character string literal must match the character set of the
corresponding SQL column. For example, if the character string literals are encoded in
Unicode format, the SQL column must be defined with the UCS2 character set. For
more information about the supported character sets, see Character Sets on
page 3-40.
To ensure that the SQLJ translator properly interprets the encoding of the SQLJ source
code, including the character string literals, specify the
-encoding option during
SQLJ translation. The
-encoding option must match the encoding you used while
writing the SQLJ source code in an IME. For more information, see -encoding on
page 5-22.
Note. The Open System Services (OSS) environment currently does not support a multilingual
IME. Use an IME on your PC or UNIX workstation to write the SQLJ source code and then port
the source file to a NonStop system for processing, or code the character string literals in
hexadecimal form. See Using Hexadecimal Values in Character String Literals
on page 3-46.
#sql {INSERT INTO dept_internatl
(deptnum, deptname, manager, rptdept, location)
VALUES (:deptNum, :deptName, :manager, :rptDept,
_UCS2' ')};