MainframeKit

+304

SQLSTATE 01515POSITIVE SQLCODE (WARNING)

A fetched value did not fit the host variable's data type, so Db2 returned null for it (indicator -2) and carried on.

MOST LIKELY

A host variable declared smaller than the column (for example PIC S9(4) COMP for an INTEGER column).

FIRST CHECK

Find the host variable at the position given in the message.

TRY IT ▸

MainframeKit assistant

What it means

During a FETCH or SELECT INTO, one value was outside the range that the receiving host variable can hold, for example a large number going into a halfword (SMALLINT) field.

Db2 does not return that value. If you supplied an indicator variable it is set to -2, and the rest of the row is processed. Without an indicator variable the situation becomes an error instead.

Typical causes

  • A host variable declared smaller than the column (for example PIC S9(4) COMP for an INTEGER column).
  • A column was altered to a larger type but the copybook was not regenerated.
  • Data values that grew beyond what the program was designed for.

How to fix it

  1. Find the host variable at the position given in the message.
  2. Compare its declaration with the column definition in SYSIBM.SYSCOLUMNS.
  3. Regenerate the declarations with DCLGEN and recompile.
  4. Check the indicator variable for -2 after each FETCH so that lost values are noticed.

Example

Illustrative only; names and values are invented.

EXEC SQL SELECT SALARY INTO :WS-SAL :WS-SAL-IND FROM EMP WHERE EMPNO = :WS-EMPNO END-EXEC
-- SQLCODE +304, WS-SAL-IND = -2 (value too large for WS-SAL)