DB2 Unicode
Driver Configuration
There are no specific environment variables that need to be set for the DB/2 Driver to handle Unicode data.
One special consideration when inserting Unicode data into the daatbase though is that you cannot insert literal Unicode values into the database.
Instead these values have to be inserted as bound parameters as follows:
CREATE TABLE UTEST (F1 GRAPHIC(20), F2 VARGRAPHIC(20), F3 LONG VARGRAPHIC, F4 DBCLOB(100)); Successfully connected to DSN 'UO_db2'. SQLBindParameter: In: StatementHandle = 0x00751860, ParameterNumber = 1, InputOutputtype = SQL_PARAM_INPUT=1, ValueType = SQL_C_WCHAR=-8, ParameterType = SQL_WCHAR=-8, ColumnSize = 0, DecimalDigits = 0, ParameterValuePtr = "?????", BufferLength = 0, StrLen_or_IndPtr = SQL_NTS=-3, SQL_LEN_DATA_AT_EXEC = FALSE, Buffer Size = 600 Return: SQL_SUCCESS=0 SQLExecDirect: In: Statementhandle = 0x00751860, StatementText = "insert into utest(f1) values(?)", Statementlength = 31 Return: SQL_SUCCESS=0 SQLExecDirect: In: Statementhandle = 0x00751860, StatementText = "select * from utest", Statementlength = 19 Return: SQL_SUCCESS=0 Get Data All: "F1", "F2", "F3", "F4" "АБВГД ", <Null>, <Null>, NO DATA 1 row fetched from 4 columns.
This is because the Graphic string data types are compatible only with other graphic string data types, and never with numeric, character string, or datetime data types.
Note that additional Unicode support has been added to the DB/2 agent for VARCHAR, LONGVARCHAR, CLOB & BLOB types, although a specific Patch (FIXPAK7) is required from IBM to obtain this support in DB/2 v 7.2 databases and FIXPAK 3 & 7 are required for DB/2 v7.1 databases.
The application code page must be set to UTF-8, which can be done by issuing the command:
db2set DB2CODEPAGE=1208
on the client (DB2 Lite) or server (DB2 agent) as appropriate.
See Also: DB2UnicodeConfig
Referenced by...