Informix Error -762
-762 Stack overflow occurred during statement parse.
This error indicates that an internal memory limitation in the SQL parser has been reached. This condition can occur if your query contains many nested expressions. For example, the query might contain many occurrences of AND and/or OR in the WHERE clause. To work around this condition, rewrite the query to eliminate some of the nested expressions.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-762 fires when the SQL parser's internal memory limit is reached — per the official guidance, a
query with many nested expressions (a common example: many AND/OR occurrences chained in a
WHERE clause) is the typical trigger.
- A
WHEREclause with a very large number of chainedAND/ORconditions, per the official guidance's own example — often generated programmatically (e.g. a largeIN-style condition expressed as repeatedORs) rather than hand-written. - Deeply nested parenthesized expressions, generally, beyond what the parser's internal
stack can handle — the same general phenomenon as chained
AND/OR, just structured differently. - Generated SQL that grows unboundedly with input size (one condition per item in a list, for example), which works fine for small inputs and only fails once the list gets large enough.
Solutions / Resolution
- Rewrite the query to eliminate some of the nested expressions, per the official guidance — this is the documented, only fix.
- Replace a long chain of
OR-ed equality conditions withIN (...), if that's the pattern involved —INwith the same value list is typically far more parser-efficient than the equivalentORchain. - For generated SQL that grows with input size, cap the number of conditions per statement and split into multiple statements/batches if a single query would otherwise generate an unbounded number of nested conditions.
Examples
A long OR chain
SELECT * FROM orders WHERE order_id = 1 OR order_id = 2 OR order_id = 3 OR ... /* hundreds more */;
-- -762: too many nested OR conditions for the parser's stack
Corrected — use IN instead
SELECT * FROM orders WHERE order_id IN (1, 2, 3, /* ... */);
Diagnostic Checks
- Count the
AND/ORconditions (or nested parenthesized groups) in the failing statement, and look for a generated-SQL pattern that could be rewritten asIN (...)or split into batches.
Related Errors / Related Topics
- -722 — "Out of stack space." A related stack-exhaustion error, in the server's general execution stack rather than specifically the SQL parser's internal limit.
Rewrite long OR chains as IN (...), and cap generated-SQL condition counts to avoid
unbounded growth with input size.