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
- Find the host variable at the position given in the message.
- Compare its declaration with the column definition in SYSIBM.SYSCOLUMNS.
- Regenerate the declarations with DCLGEN and recompile.
- 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)