The application code page is derived from the active environment when the database connection is made. If the DB2CODEPAGE registry variable is set, its value is taken as the application code page. However, it is not necessary to set the DB2CODEPAGE registry variable because DB2® will determine the appropriate code page value from the operating system. Setting the DB2CODEPAGE registry variable to incorrect values can cause unpredictable results.
When you create a database, you can explicitly specify the database code page. If you do not specify the database code page, the database will use Unicode by default.
The following defines how the active environment is determined in different operating environments in the following ways:
Normally, Windows will not report a Unicode code page in place of the aforementioned ANSI code page. Therefore, a Windows application will typically not behave as a Unicode client. To override this behavior, the DB2CODEPAGE variable can be set to a Unicode code page (1208), which will force the application to behave as a Unicode client.
The section code page is derived from the tables used in an SQL statement. If the tables are implicitly or explicitly defined with CCSID ASCII, then the section code page is the same as the database code page. If the tables are defined with CCSID UNICODE, then the section code page is the Unicode code page.
At precompile/bind time, the precompiler is the executing application. The active code page when the database connection was made before the precompile request is used for precompiled statements, and any character data returned in the SQLCA.
At execution time, the active code page of the user application when a database connection is made is in effect for the duration of the connection. All data is interpreted based on this code page; this includes dynamic SQL statements, user input data, user output data, and character fields in the SQLCA.