Informix Error -647: Error evaluating math library function function-name.
Cause and resolution
Error evaluating math library function function-name.
The data type of the argument is correct, but the value passed to the function is not appropriate for the math function. Check that you are passing a legitimate value to the function.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-647 fires when a math library function (SQRT, LOG, LN, EXP, and similar) is called with
a value of the correct type but one that's mathematically invalid for that function — per the
official guidance, the data type is fine; the specific value passed isn't appropriate.
SQRT()(or another function requiring a non-negative argument) called with a negative value — a classic example of a type-correct but mathematically invalid input.LOG()/LN()called with zero or a negative value, since logarithms aren't defined there.- A calculation feeding an out-of-domain intermediate value into a math function, where the invalid value wasn't obvious at the point the function call was written, because it depends on the data.
Solutions / Resolution
- Check that a legitimate value is being passed to the function, per the official guidance —
review the function's mathematical domain (non-negative for
SQRT, positive forLOG/LN, etc.) against what the expression can actually produce. - Add a guard condition (a
CASEexpression or aWHEREclause filter) to exclude out-of-domain values before they reach the math function, if the underlying data can legitimately contain them. - Trace back through the expression feeding the function call if the invalid value isn't supplied directly as a literal, to find where an out-of-domain value is being produced.
Examples
An out-of-domain argument
SELECT SQRT(balance) FROM accounts;
-- -647: some accounts have a negative balance
Guarding against it
SELECT CASE WHEN balance >= 0 THEN SQRT(balance) ELSE NULL END FROM accounts;
Diagnostic Checks
- Identify the specific math function named in the error and check its mathematical domain.
- Query for rows whose computed argument falls outside that domain, to confirm which data is
triggering the failure:
SELECT * FROM accounts WHERE balance < 0;
Related Errors / Related Topics
No closely related error codes are cross-referenced for -647 in this set yet.
A domain error, not a type error — check the function's valid input range against what the underlying data can actually produce, and guard against out-of-domain values.