Troubleshooting
Problem
Receive an SQL0302N error when inserting non-ASCII character data into tables if the database is defined with code set UTF-8.
Symptom
When working with character string data in UTF-8, you should not assume that each character is one byte. In multibyte UTF-8 encoding, each ASCII character is one byte, but non-ASCII characters take two to four bytes each. This should be taken into account when defining CHAR/VARCHAR fields if you plan to use any non-ASCII characters.
See the Related URL section for a link to the IBM Information Center which has a complete description of the error message.
Resolving The Problem
Depending on the ratio of ASCII to non-ASCII characters, a CHAR field of size n bytes can contain anywhere from n/4 to n characters.
Check the database configuration to find the database code page.
db2 "GET DB CFG FOR sample"
Here is the sample output:
Database code page = 1208
Database code set = UTF-8
Database country/region code = 1
Increase the length of the column for the char/Varchar column for existing table based on your requirement. Here is a sample command.
db2 "ALTER TABLE Employee ALTER COLUMN EmplNum SET DATA TYPE VARCHAHR(256)"
Related Information
Was this topic helpful?
Document Information
Modified date:
23 June 2018
UID
swg21410823