The C/C++ Precompiler supports the use of UNICODE data in MaxDB application programs. The only permitted coding formats are UCS2 or UTF-16 (without surrogate), both with a platform-specific byte configuration. All output in the trace file is in UTF 8.
You can use UNICODE character strings in the following locations in host variables only:
You cannot use UNICODE application programs with ASCII database instances.
You have installed a UNICODE-compliant database instance.
After a CONNECT statement, the precompiler can recognize automatically whether it is connected to a UNICODE-compliant database instance.
· Use suitable host variables with the appropriate predefined UNICODE data types for your UNICODE character strings.
· If the user name or password contains UNICODE characters, then also use UNICODE host variables.
· If host variables contain complete SQL statements, then these statements are sent as ASCII or UNICODE character strings, depending on the type of the host variables. For performance reasons, only use UNICODE host variables for an SQL statement if the statement actually contains UNICODE characters.
· Run the precompiler with the precompiler option –G unicode.
EXEC SQL BEGIN DECLARE SECTION;
/* "SELECT TABLENAME FROM DOMAIN.TABLES " encoded in UCS2 */
SQLUCS2 sqlstmt[36] = {0x0053, 0x0045, 0x004C, 0x0045, 0x0043,
0x0054, 0x0020, 0x0054, 0x0041, 0x0042,
0x004C, 0x0045, 0x004E, 0x0041, 0x004D,
0x0045, 0x0020, 0x0046, 0x0052, 0x004F,
0x004D, 0x0020, 0x0044, 0x004F, 0x004D,
0x0041, 0x0049, 0x004E, 0x002E, 0x0054,
0x0041, 0x0042, 0x004C, 0x0045, 0x0053,
0x0000};
SQLUCS2 resultstring[64];
EXEC SQL END DECLARE SECTION;
/* connect ... */
/* parse a unicode sql command and give it a statement name */
EXEC SQL PREPARE stmt1 FROM :sqlstmt;
EXEC SQL DECLARE curs1 CURSOR FOR stmt1;
EXEC SQL OPEN curs1;
/* loop over resultset */
while (sqlca.sqlcode != 100)
{
EXEC SQL FETCH curs1 INTO :resultstring;
/* ... */
}
EXEC SQL CLOSE curs1;