Informix Error -3761: ERROR -- attempt to divide by zero has occurred.
Cause and resolution
ERROR -- attempt to divide by zero has occurred.
A division expression in the INSTRUCTIONS section has a zero divisor. Review all uses of division in the INSTRUCTIONS section, and look for any that might have a denominator of zero (possibly the denominator is a field into which the user entered a zero). Protect these expressions with tests for zero using IF-THEN-ELSE.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-3761 fires when a division expression in INSTRUCTIONS has a zero divisor at runtime — per
the official guidance, the denominator might be a field into which the user entered a zero.
- A division expression whose denominator evaluates to zero, per the official guidance — the direct, only cause.
Solutions / Resolution
- Review all uses of division in the
INSTRUCTIONSsection, per the official guidance. - Protect these expressions with tests for zero using
IF-THEN-ELSE, per the official guidance.
Examples
An unprotected division
INSTRUCTIONS
AFTER QUERY OF orders
LET avg_price = total / qty;
-- -3761: qty may be zero
END
END
Corrected
INSTRUCTIONS
AFTER QUERY OF orders
IF qty <> 0 THEN
LET avg_price = total / qty;
ELSE
LET avg_price = 0;
END IF
END
END
Diagnostic Checks
- Check every division expression in
INSTRUCTIONSfor a denominator that could be zero, and guard it withIF-THEN-ELSE.
Related Errors / Related Topics
No closely related error codes are cross-referenced for -3761 in this set yet.
A division expression's denominator evaluated to zero at runtime — guard it with
IF-THEN-ELSE.