# SQLCODE +445: Value has been truncated

Source: https://wndsoftware.com/mainframe-errors/sqlcode-plus-445

### SQLCODE +445: Value has been truncated

SQLCODE +445 (SQLSTATE 01004) is a warning that Db2 truncated a value while casting it to another type or length. The cast can come from a CAST specification, a built-in function such as CHAR or VARCHAR, or a user-defined function, and the message shows the value that was cut.


#### Other names for this code

Also written as `SQLCODE 445`, `SQLCODE=+445`, `SQLCODE = 445`, `sqlcode +445`, `db2 +445`, `sqlstate 01004`, `value has been truncated`, `SQL0445W`.


### What it means

Db2 converts values from one data type or length to another all the time. When the target is shorter than the value, Db2 may cut it to fit. If that happens inside a cast function, Db2 returns +445 to say the result isn't the whole value. The statement still completes.

Db2 for z/OS lists four sources of the cast.

- A CAST specification in the statement, such as CAST(DESCRIPTION AS CHAR(20)).
- A built-in function such as CHAR or VARCHAR given a length shorter than the data.
- A CAST FROM clause in the CREATE FUNCTION statement for an external function.
- A sourced user-defined function whose result had to be converted.

If the value is FOR BIT DATA, the message shows it as a hex string in quotes followed by an X.

SQLSTATE 01004 is also what Db2 uses when a string is cut short on its way into a host variable. That case is signalled with the SQLWARN1 flag in the SQLCA and the indicator variable rather than with +445, so check the SQLCODE to see which one you have.


### Common causes

- A CAST to a shorter CHAR or VARCHAR in a SELECT list or view definition, such as to fit a report column.
- CHAR or VARCHAR called with a length that is shorter than some of the data.
- A user-defined function whose CAST FROM type is shorter than the values it returns.
- Columns were widened in the table, but views and queries still cast to the old length.


### How to find the problem

- Read the value in the message. It shows exactly what was cut, which usually identifies the column.
- Search the statement and any views it uses for CAST, CHAR and VARCHAR with explicit lengths.
- For user-defined functions, check the CAST FROM clause in the function's definition.
- Compare the cast length with the column's length in SYSIBM.SYSCOLUMNS and with the longest actual value.


### How to fix it

- Make the cast or function length large enough for the data.
- If shortening is intended, use SUBSTR or a similar function so the intent is clear and the warning goes away.
- Update views and functions after widening columns.
- Check SQLCODE warnings in the program, so truncated values aren't written to files or other tables unnoticed.


### IBM documentation

[IBM Db2 for z/OS documentation](https://www.ibm.com/docs/en/db2-for-zos/13.0.0). Use the documentation for your installed release.

This link opens the relevant IBM reference library or lookup instructions. Match the complete code and your installed product release; it is not a code-specific review.

[Report a correction to WND Software](https://wndsoftware.com/contact#message).

Technical reviewer: [Albert Joseph](https://wndsoftware.com/authors/albert-joseph), WND Software.

Last reviewed 2026-10-18 by the WND Software team. Written in our own words. For the full reference, check IBM’s Db2 for z/OS documentation for your release.


### Related codes

[SQLCODE -433 Value too long Read →](https://wndsoftware.com/mainframe-errors/sqlcode-433)
[SQLCODE -302 Input value invalid or too large Read →](https://wndsoftware.com/mainframe-errors/sqlcode-302)
[SQLCODE +304 Value out of range for host variable (warning) Read →](https://wndsoftware.com/mainframe-errors/sqlcode-plus-304)
[SQLCODE -404 String too long for the column Read →](https://wndsoftware.com/mainframe-errors/sqlcode-404)
[SQLCODE +802 Arithmetic exception (warning) Read →](https://wndsoftware.com/mainframe-errors/sqlcode-plus-802)

### Questions


#### Did the statement fail?

No. +445 is a warning. The statement completed, but at least one value in the result was shortened.


#### Why doesn't every truncation give +445?

+445 is for truncation inside a cast function. A string that is too long for its host variable is reported through SQLWARN1 and the indicator variable instead.


#### How do I find which value was truncated?

The message includes the truncated value. Match it to the column it came from.

[Db2 SQLCODEs](https://wndsoftware.com/mainframe-errors/db2-sqlcodes) · [SQLCODE +394](https://wndsoftware.com/mainframe-errors/sqlcode-plus-394) · [SQLCODE +802](https://wndsoftware.com/mainframe-errors/sqlcode-plus-802)

[← All error codes](https://wndsoftware.com/mainframe-errors/)
