I've got SQL for DB2 of the following abbreviated format:
Select ...
From ...
Where ... ((COL1 IS NULL) And ('' = ?)) ...
Order By ...
The rough purpose of this SQL is to return Null records if the input against COL1 is blank.
However, if I try to bind 'RED' to the placeholder, I get a CLI0109E error indicating 'string data right truncation.' I believe what is happening is that DB2 has decided that the '' literal in the SQL is a column of length 0, and so trying to compare a bound parameter of length 3 (in the case of 'RED') causes the truncation error. This would make sense.
If I change the SQL to: ((COL1 IS NULL) And ('{10 spaces}' = ?))
, it works fine.
If I change the SQL to: ((COL1 IS NULL) And (CAST('' AS VARCHAR(32767)) = ?))
, it works fine.
Is there a driver setting, or an SQLBindParameters setting that I'm missing that's causing DB2 to interpret the '' as a zero-length column?
I run the same SQL through Oracle and SQLServer and they work fine, which tells me they interpret '' as something different, and maybe by default treat all literals in the SQL as VARCHAR(32767) or something.
Thanks for any help.