04 February 2009

IBM DB2 Error: SQLSTATE=22001; String Data Right Truncation

Here is one of those basic IBM DB2 errors that can be thrown at you. From the name, one can easily determine what the cause of the error is. Take a look at the following error:

[IBM][CLI Driver] CLI0109E String data right truncation. SQLSTATE=22001

So what is up with this error? If you have any programming background, the error message is very easy to decipher, which is God send for an IBM product (I think IBM write their manuals and error messages in way that is designed to frustrate people even more, just for the kicks).

Basically, if you have a field definition that takes a maximum number of characters, say a VARCHAR(20) and you try to insert data into that field that is MORE than those maximum characters, you will get this error.

So for our example of a VARCHAR(20) field, passing in a string that is 21 characters will trigger the error.

So how to avoid it? I think it is pretty obvious ... make sure your field definitions adhere to your input data!

No comments:

Post a Comment

Feel free to write any comments or ideas!

IBM DB2 Error: SQLSTATE=22001; String Data Right Truncation

Here is one of those basic IBM DB2 errors that can be thrown at you. From the name, one can easily determine what the cause of the error is. Take a look at the following error:

[IBM][CLI Driver] CLI0109E String data right truncation. SQLSTATE=22001

So what is up with this error? If you have any programming background, the error message is very easy to decipher, which is God send for an IBM product (I think IBM write their manuals and error messages in way that is designed to frustrate people even more, just for the kicks).

Basically, if you have a field definition that takes a maximum number of characters, say a VARCHAR(20) and you try to insert data into that field that is MORE than those maximum characters, you will get this error.

So for our example of a VARCHAR(20) field, passing in a string that is 21 characters will trigger the error.

So how to avoid it? I think it is pretty obvious ... make sure your field definitions adhere to your input data!

0 Comments:

Post a Comment

Feel free to write any comments or ideas!