Question & Answer
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
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.
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.
16 June 2018