SQL/MX Programming Manual for Java
SQLJ Programming
HP NonStop SQL/MX Programming Manual for Java—523726-003
3-42
Character String Data Types
Assigning (or Comparing) Character String Data to an SQL
Column
This subsection describes:
•
Assigning Character String Data to an SQL/MP KANJI or KSC5601 Column on
page 3-42
•
Assigning Character String Data to an SQL/MX UCS2 Column on page 3-43
•
Comparing Character String Data With an SQL/MX ISO88591 Column on
page 3-44
For more information about input host variables, see Host Variables and Expressions
on page 3-27.
Assigning Character String Data to an SQL/MP KANJI or KSC5601 Column
Consider an SQLJ program that modifies an SQL/MP table with a column named
LOCATION that stores Japanese characters in KANJI character-set format:
CREATE TABLE $samdb.persnl.dept_japan
( deptum NUMERIC (4) UNSIGNED
NO DEFAULT
NOT NULL
...
,location VARCHAR (18) CHARACTER SET KANJI
...
In the SQLJ program, code the host variable declaration and UPDATE statement as:
Shift-JIS is the appropriate encoding for Japanese characters to be assigned to or
compared with an SQL/MP KANJI character-set column.
EUC_KR is the appropriate encoding for Korean characters to be assigned to or
compared with an SQL/MP KSC5601 character-set column.
To ensure the proper encoding of character string literals, set the -encoding option
during translation of the SQLJ program. For more information, see -encoding on
page 5-22.
String city = new String(" "); /* String literal encoded
as Shift-JIS */
...
#sql {UPDATE dept_japan
SET location = :city
WHERE deptnum = 1000};
...