What it means
While working out an expression in the select list, Db2 hit an arithmetic exception such as decimal overflow, fixed-point overflow or division by zero. The message tells you the exception type and the position of the item in the select list.
Db2 sets the indicator variable for that item to -2, leaves the host variable unchanged, and returns the rest of the row. A cursor stays open. The cause is usually in the data, not in the program.
Typical causes
- Division by zero in an expression such as AMOUNT / QTY when QTY is 0.
- A result too large for the result data type (decimal or integer overflow).
- Expressions that combine very large and very small numbers.
How to fix it
- Find the select-list item at the position given in the message.
- Guard the expression, for example CASE WHEN QTY = 0 THEN NULL ELSE AMOUNT / QTY END.
- Widen the result with CAST or DECIMAL if overflow is the problem.
- Always check indicator variables for -2 after the FETCH.
Example
Illustrative only; names and values are invented.
SELECT AMOUNT / QTY FROM MYSCHEMA.ORDERS
SQLCODE +802: ZERO DIVIDE for select item 1, indicator set to -2