I'm having trouble with a piece of SQL code in an UPDATE statement on DB2 9.1 using JDBC. The idea is to concatenate a java String and a column value in the same row to set another column. So it's setting a varchar(800) to the concatenation of a short String and a varchar(80) column value in the same row. The varchar(80) value is not set in the update. The code to set the varchar(800) column is
-
TABLER.TR_LIB_LONG = CAST(? AS CHAR)||CAST(TABLER.TR_LIB AS CHAR)
-
This sometimes works, but on certain rows I always get a DB2 error -302 with SQLSTATE 22001. However, if I take out the parameter marker and hardcode the String in the SQL, it works without error.
Any idea what's going on here?
The error code description suggests that the concatenated String is too long, but the inputs which provoke the error are quite short (e.g. if I pass in 'foo/' as the parameter and the TR_LIB value is 'bar').