Nul-termination of strings
By default, character strings that Db2 ODBC return are terminated with a nul-terminator (hex 00), except for strings that are returned from the graphic and DBCLOB data types into SQL_C_CHAR application variables.
Graphic and DBCLOB data types that are retrieved into SQL_C_DBCHAR and SQL_C_WCHAR application variables are nul-terminated with a double-byte nul-terminator (hex 0000). This requires that all buffers allocate enough space for the maximum number of bytes expected, plus the nul-terminator.
You can also use SQLSetEnvAttr() and set an environment
attribute to disable nul-termination of varying-length output (character
string) data. In this case, the application allocates a buffer exactly
as long as the longest string it expects. The application must provide
a valid pointer to storage for the output length argument so that Db2 ODBC can indicate the actual
length of data returned; otherwise, the application has no means to
determine this. The Db2 ODBC
default is to always write the nul-terminator.