Define variables for locale-sensitive data
The SQL data types NCHAR and NVARCHAR support locale-specific data, in the sense that the database server uses localized collation (if the locale defines localized collation), rather than code set order, for sorting data strings of these types.
For more information about NCHAR and NVARCHAR data types, see Character data types.
Informix® ESQL/C supports the predefined data types string, fixchar, and varchar for host variables that contain character data. In addition, you can use the C char data type for host variables. You can use these four host-variable data types for NCHAR and NVARCHAR data.
/*
This code fragment declares a char host variable "hte",
which contains a non-ASCII character in the name, and
selects NCHAR data (non-ASCII names in the "nom" column
of the "abonns" table) into it.
*/
EXEC SQL BEGIN DECLARE SECTION;
char hte[10];
...
EXEC SQL END DECLARE SECTION;
...
EXEC SQL select nom into :hte from abonns
where numro > 13601;
- If your locale supports a single-byte code set, the size of the NCHAR and NVARCHAR variable determines the number of characters that it can hold.
- If your locale supports a multibyte code set, you can no longer assume a one-byte-per-character
relationship.
In this case, you must ensure that you declare the Informix® ESQL/C host variable large enough to accommodate the number of characters that you expect to receive from the database.
For more information, see The NCHAR data type and The NVARCHAR data type.
You can insert a value that a character host variable (char, fixchar, string, or varchar) holds in columns of the NCHAR or NVARCHAR data types.