RPG (IBM i / AS/400) · DB2 SQLCODE

SQLCODE -802 - Arithmetic Exception

What does SQLCODE -802 - Arithmetic Exception mean in RPG (IBM i / AS/400)?

An SQL statement performed an arithmetic operation - commonly a division by zero, or a computation whose result overflowed the target column's or host variable's precision - while executing inside the SQLRPGLE program.

SQLCODE -802 - Arithmetic ExceptionDB2 for i · SQLRPGLE

Condition

An SQL statement performed an arithmetic operation - commonly a division by zero, or a computation whose result overflowed the target column's or host variable's precision - while executing inside the SQLRPGLE program.

Fix

Guard division in the SQL statement (a CASE or NULLIF around the divisor) the same way you'd guard native RPG arithmetic, and size result columns/host variables large enough for the values the calculation can actually produce.

Related db2 sqlcode