SQLCODE -433: Value too long
SQLCODE -433 (SQLSTATE 22001) means a value is too long for the place it's going, and Db2 isn't allowed to shorten it there. It shows up with function arguments, casts, LOB values and XML, and the message shows the value itself instead of a column name.
Other names for this code
Also written as SQL -433, SQLCODE=-433, SQLCODE = -433, db2 -433, sqlstate 22001, SQL0433N, db2 value is too long, SQL0433, sqlcode -433 xml.
What it means
When Db2 passes a value somewhere with a fixed length, it sometimes has to adjust it with a built-in cast. If that cast would have to cut the value short, and cutting isn't allowed in that context, Db2 fails the statement with -433. IBM lists four places this happens. They are an argument to a user-defined function, the SET clause of an UPDATE, a value being inserted, and the input to a cast elsewhere in the statement.
The message token is the value, not the target. Binary data, and character data defined FOR BIT DATA, is shown as a hex string in quotes followed by X. A long value may be cut off in the message.
Compare -404, a string too long for its target column, and -302, which points to a host variable by position. -433 is the one you see when a cast sits between the value and its target.
Common causes
- A string longer than a user-defined function's parameter is passed as an argument, for example 30 characters to a VARCHAR(20) parameter.
- A LOB value is larger than the maximum length of the LOB column it's inserted into. IBM has seen this from applications that store large documents or rule sets as BLOBs.
- An XML value is serialized or fetched into a character target that is shorter than the document.
- A literal in the SQL is longer than the target it's assigned to through a function or cast.
How to find the problem
- Read the value in the message, or in SQLERRMC, and search the statement and the program's input for it.
- Find the target it goes to. For a function argument, check the parameter length in SYSIBM.SYSPARMS. For a column, check SYSIBM.
SYSCOLUMNS. - For LOB columns, compare the length of the value with the column's maximum length.
- For XML, check the length of the serialized document against the host variable or the type in XMLSERIALIZE.
How to fix it
- Shorten the input with SUBSTR or LEFT if losing the end is acceptable.
- Make the target larger. That can mean a longer function parameter, which usually means dropping and re-creating the function, or a LOB column with a larger maximum.
- For XML, serialize to a CLOB, or fetch with FETCH WITH CONTINUE, which lets a program read a long LOB or XML value in pieces.
- Validate the length of input before it reaches the SQL.
IBM documentation
IBM documentation: -433. Use the documentation for your installed release.
Related codes
Questions
Why does the message show my data and not a column name?
-433 reports the value that couldn't be shortened. Use the value to find where it's used in the statement, then check that target's length.
What is the difference between -433 and -404?
-404 is a string that is too long for the column or other target it is assigned to. -433 comes from a cast or function that would have to truncate the value, so it shows the value instead.
Is SQL0433N on Db2 for LUW the same?
Yes. Db2 for LUW reports SQL0433N, value is too long, with SQLSTATE 22001.