tags:

views:

102

answers:

0

I have a legacy C code that selects a row using multiple add_field method calls part of DB2 C API. I really do not know how this method is implemented. But by looking at the code, I can see that all columns are bound to their variable counterparts using this method. Sample call looks like this:

add_field("acct_num", SQL_VARCHAR, accountNumber);

When the row is first selected, I do not get any error. However, whenever I update any column in the table through the code and do a select again (same function call and query), it results in the following error.

CLI0112E  Error in assignment. SQLSTATE=22005

I was able to identify the root cause of the error quite easily. It was a case of data type incompatibility for one variable and its corresponding column. The column was defined as type CHAR whereas the add_field call for that was having SQL_INTEGER.

However, I can't quite understand as to why the first select query did not show me this error? Any help is appreciated.

Thanks.