Code-set conversion

If you have a character buffer to hold character data from a database, you must ensure that this buffer is large enough to accommodate any expansion that might occur if the application uses code-set conversion. If the client and database locales are different and convertible, the application might need to expand this value.

For more information, see ids_gug_053.html#ids_gug_053.

For example, if the fname column is defined as CHAR(8), the following HCL OneDB™ ESQL/C code fragment selects an 8-byte character value into the 10-byte buf1 host variable:
char buf1[10];
...
EXEC SQL select fname into :buf1 from tab1 
         where cust_num = 29;

You might expect a 10-byte buffer to be adequate to hold an 8-byte character value from the database. If the client application expands this value to 12 bytes, however, the value no longer fits in the buf1 buffer. The fname value is truncated to fit in buf1, possibly creating partial characters if fname contains multibyte characters. For more information, see Partial characters in column substrings.

To avoid this situation, define buffers to handle the maximum character-expansion possible, 4 bytes, in the conversion between your client and database code sets.