Help SQL Replication

Code pages for SQL Replication

The code page configuration for replication is defined when you set up database connectivity between systems. However, if you are running the Capture or Apply programs on Linux, UNIX or Windows operating systems, some configuration steps might be necessary.

On Linux, UNIX, and Windows, the Capture program must run in the same code page as the database from which it is capturing the data. If the Capture program is not run in the same code page, you must set a DB2® environment variable or registry variable called DB2CODEPAGE so that Capture uses the same code page as the database.

When the Apply program runs on Linux, UNIX, or Windows, if any source table is in UNICODE, the Apply application code should be in UNICODE. If the data in the source table is in ASCII, the application code page should be in ASCII. You can also set the DB2CODEPAGE variable for the Apply program.

Setting the code page variable
DB2 derives the code page for an application from the active environment in which the application is running. Typically, when the DB2CODEPAGE variable is not set, the code page is derived from the language ID that is specified by the operating system. In most situations, this value is correct for the Capture or Apply programs if you use the default code page when you create your database. However, if you create your database with an explicit code page that is something other than the default code page, you must set the DB2CODEPAGE variable. Otherwise, data might not be translated correctly. The value that you use for the DB2CODEPAGE variable must be the same as what you specify on your CREATE DATABASE statement. See the DB2 Information Center for details about setting the DB2CODEPAGE variable.
Replicating from a code page
If you are replicating source data with a single-byte character set (SBCS) code page to a target with Unicode UTF-8, some single-byte characters in the source database might be translated by DB2 to two or more bytes in the target database. All single-byte characters whose hexadecimal value is 0x80 to 0xff are translated to their two-byte 1208 equivalent. This means that target columns might need to be larger than source columns, otherwise the Apply program might receive SQL errors from DB2.

Some database products implement code page support differently from others, which can impact your replication configuration. For example, DB2 on System i® allows a code page to be specified at the column level, but DB2 for Linux, UNIX, and Windows allows a code page to be specified only at the database level. Therefore, if you have a System i table with multiple columns using different code pages, those columns cannot be replicated to a single DB2 for Linux, UNIX, and Windows database unless all the code pages are compatible.

Setting the LANG variable
If you are running the Capture and Apply programs on a Linux or UNIX system, you might need to set the LANG environment variable. The Capture and Apply programs use the contents of this environment variable to find their message library for your language. For example, if the LANG environmental variable is set to en_US, the Capture program looks for its English message library in the DB2 instance's /sqllib/msg/en_US subdirectory. If Capture cannot find its message library, all messages written to the IBMSNAP_CAPTRACE table are ASN0000S.


Send your feedback | Information roadmap | The Q+SQL Replication Forum

Update icon Last updated: 2013-10-25