I have an array of unsigned chars that I need to insert into a field of a table that is defined as a BLOB(30000). The following is the insert statement I've been trying to use along with the bind parameter call for the field in question.
Code:
char *insertStmt =
"INSERT INTO TESTTABLE (CATEGORY, TOPIC, DATA) VALUES(?, ?, CAST(? AS BLOB(30000)))";
Code:
SQLBindParameter(handleStmt, 3, SQL_PARAM_INPUT, SQL_C_BINARY,
SQL_BLOB, (SQLUINTEGER)30000, 0, ptr, (SQLINTEGER)30000, &sqlNts);
ptr in the above code is defined as unsigned char ptr[30000];
The issue I have with this is if a NULL character occurs anywhere in this array, then all characters occurring after the initial NULL are being truncated from what's getting inserted into the database. When I do a select * on this table, the field for the BLOB always only has the bytes that occurred before the first byte representing the NULL character.
Is there a way to do this such that I can get the full array of bytes stored in to the BLOB and not have this issue with bytes that would represent the NULL character?
DB2 version - 9.1.0.9, Fix Pack - 9, DB2 type - ESE