Informix Error -9140
Cause and resolution
An attempt was made to divide by zero on line number. The result was set to zero.
An expression on line number of the report-specification file contains a division operation. At some point in the report run, the divisor in the expression was zero. Examine the expression and the data it uses and write the report so that division by zero will not occur (for example, by testing for zero in an IF statement). This error can result from applying an aggregate function to a defined variable before the first row of data is processed. To avoid this situation, make sure that any variable has a value before it is used (for example, by setting it from a command-line parameter or with a PROMPT FOR statement).
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-9140 fires when an expression on the named line of the report specification divides by zero during the report run — per the official guidance; the result is set to zero and execution continues.
- A divisor that evaluates to zero at some point during the report run, per the official guidance — the direct, primary cause.
- An aggregate function applied to a defined variable before the first row of data is processed, per the official guidance — this can also produce a zero divisor.
Solutions / Resolution
- Examine the expression and the data it uses, and write the report so division by zero won't occur — for example, by testing for zero in an IF statement, per the official guidance.
- Make sure any variable used in the expression has a value before it's used — for example, by setting it from a command-line parameter or with a PROMPT FOR statement, per the official guidance.
Examples
An unguarded division
LET ratio = numerator / denominator -- -9140 if denominator is 0
Corrected — guarding the division
IF denominator <> 0 THEN
LET ratio = numerator / denominator
ELSE
LET ratio = 0
END IF
Diagnostic Checks
- Check the named line number's expression for an unguarded divisor, and check whether any variable it uses is still unset when the aggregate/expression first evaluates.
Related Errors / Related Topics
No closely related error codes are cross-referenced for -9140 in this set yet.
A division by zero occurred at the named line; the result was set to zero — guard the division with a zero check, and make sure variables have values before use.