MainframeKit

+445

SQLSTATE 01004POSITIVE SQLCODE (WARNING)

A value was cut short when Db2 cast it to a shorter data type, for example by CAST, CHAR or VARCHAR.

MOST LIKELY

CAST(column AS CHAR(n)) or VARCHAR(column, n) with n smaller than the data.

FIRST CHECK

Find the cast or function in the statement that shortens the value.

TRY IT ▸

MainframeKit assistant

What it means

A casting operation produced a value longer than the target type, so Db2 truncated it. This can come from a CAST specification, from built-in functions such as CHAR or VARCHAR, or from user-defined functions that cast their parameters.

The statement completes, but the returned value is shorter than the original.

Typical causes

  • CAST(column AS CHAR(n)) or VARCHAR(column, n) with n smaller than the data.
  • A user-defined function whose parameter or return type is shorter than the input.
  • A sourced function that needs a conversion.

How to fix it

  1. Find the cast or function in the statement that shortens the value.
  2. Make the target length big enough, or trim the data deliberately.
  3. Check that the truncated output does not cause wrong results further on.