SQL/MX 2.x Reference Manual (H06.04+)

SQL/MX Language Elements
HP NonStop SQL/MX Reference Manual540440-003
6-22
Character String Data Types
SQL/MX, and you can select from the ISO88591, UCS2, KANJI or KSC5601 character
sets. If you do not make a selection, the default is UCS2.
For SQL/MP tables, a character data type has an associated character set and
collation that can be implicitly or explicitly specified. The CHAR data type can be
associated with any of the character sets, and the NCHAR data type is typically
associated with the KANJI and KSC5601character sets.
For more information, see Character Sets on page 6-3 and Database Object Names on
page 6-12.
NCHAR Columns in SQL/MX and SQL/MP Tables
In NonStop SQL/MX and NonStop SQL/MP, the NCHAR type specification is
equivalent to:
NATIONAL CHARACTER
NATIONAL CHAR
CHAR ... CHARACTER SET ..., where the character set is the default character
set for NCHAR
Similarly, you can use NATIONAL CHARACTER VARYING, NATIONAL CHAR
VARYING, and VARCHAR ... CHARACTER SET ... .
SQL/MP Considerations for Character String Data Types
Selecting NCHAR Columns
NonStop SQL/MX supports accessing KANJI- or KSC5601-aliased NCHAR columns in
an SQL/MP table. For example, suppose that an SQL/MP table has an NCHAR column
defined as:
MPNcharCol NCHAR(10)
You can select from this column as shown:
SELECT MPNcharCol FROM MPTable;
This query returns ten characters for each row.
Using the CHAR Keyword in the CAST Operation
You can also use the CAST operation to ensure a certain number of characters are
returned from a query. For example:
SELECT CAST(MPNcharCol AS CHAR(5) character set KANJI) FROM
MPTable;
This query returns five characters for each row.
Note. SQL/MX tables do not support the KANJI or KSC5601 character sets. If you attempt to
create an SQL/MX table with these or other unsupported character set types, an SQL error is
returned and the operation fails.