IBM Support

Setting DB2CODEPAGE=1208 may result in incorrect character data insertion, SQL0191N

Question & Answer


Question

An application may fail on retrieval or insertion of data with SQL0191N Error occurred because of a fragmented MBCS character. SQLSTATE=22504 and some characters may display incorrectly, if the database utilizes UTF-8 encoding (codepage), and the system character encoding is not UTF-8 (e.g. Windows, default codepage 1252) but the application codepage is manually set to 1208 using the DB2 registry variable DB2CODEPAGE=1208

Cause

If the DB2 Registry variable DB2CODEPAGE is set to 1208 on the client instance the application is run from, and the database codepage is also 1208 (UTF-8), any data inserted to or retrieved from the database will be assumed to be in codepage 1208, so no codepage conversion will occur. If the system codepage for the application is not in fact 1208, then any characters that are not the same hex value ('code point') in both system and database codepages ,will be inserted (or displayed) incorrectly.

For example, codepages 1208 (UTF-8) and 1252 (Windows West European Latin) share a subset of code points 0x'00'-0x'7F' (the standard US ASCII character set) while the Latin Extended-A and Extended-B characters have different code point values in these respective code pages. If data residing on a system using Windows codepage 1252, and containing special (Latin Extended) characters (e.g. ä, í, é) is inserted into a DB2 UTF-8 database using an application that utilizes the DB2 client layer (e.g. ODBC or JDBC Type 2 connection), and DB2CODEPAGE=1208, then the special characters will be inserted incorrectly. Upon retrieval from an application on another system where DB2CODEPAGE=1208 is not set, the data may be displayed incorrectly or the application may return an error attempting to return the data, such as SQL0191N.

Answer

Do not set DB2CODEPAGE unless explicitly stated in DB2 documentation, or directed to by IBM DB2 service personnel. Setting DB2CODEPAGE otherwise may produce unexpected results. Normally, setting DB2CODEPAGE is not required because DB2 derives the code page information from the operating system, and converts the data between the application and database code pages automatically.

Internal Use Only

This technote was generated by Technote Kickstart 1.0.0.75 based on Information Management PMR 88222,499,000.
View the associated PMR's text via Wellspring at: http://eclient.lenexa.ibm.com:9082/DocFetcher/source/PMR/88222.499.000%20O12/06/13

[{"Product":{"code":"SSEPGG","label":"DB2 for Linux- UNIX and Windows"},"Business Unit":{"code":"BU001","label":"Analytics Private Cloud"},"Component":"Connectivity - Other","Platform":[{"code":"PF033","label":"Windows"},{"code":"PF002","label":"AIX"},{"code":"PF027","label":"Solaris"},{"code":"PF016","label":"Linux"},{"code":"PF010","label":"HP-UX"}],"Version":"9.8;9.7;9.5;9.1;10.1;8.2","Edition":""}]

Document Information

Modified date:
16 June 2018

UID

swg21601028