Informix Error -944: Cannot use "first", "limit" or "skip" in this context.
Cause and resolution
Cannot use "first", "limit" or "skip" in this context.
This statement uses FIRST N , LIMIT N or SKIP M inside a subquery. This action is not supported.
Review the use of FIRST N and check that it is applied only to the outer main query SELECT clause.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-944 fires when FIRST N, LIMIT N, or SKIP M is used inside a subquery — per the official
guidance, these clauses are only supported on the outer main query's SELECT, not within a
nested subquery.
FIRST N/LIMIT N/SKIP Mused inside a subquery, per the official guidance — the direct, only cause.- A query pattern that works for the outer
SELECT, mistakenly applied to a subquery expecting the same row-limiting behavior there.
Solutions / Resolution
- Review the use of
FIRST N/LIMIT N/SKIP Mand confirm it's applied only to the outer main query'sSELECTclause, per the official guidance. - If row-limiting is genuinely needed within what would be a subquery, restructure the query
— for example, materialize the limited subquery's result into a temp table first via its own
top-level
SELECT ... INTO TEMP, then join against that temp table in the outer query.
Examples
The disallowed attempt
SELECT * FROM orders WHERE order_id IN
(SELECT FIRST 10 order_id FROM order_items ORDER BY item_count DESC);
-- -944: FIRST used inside a subquery
Corrected — materialize the limited result first
SELECT FIRST 10 order_id FROM order_items ORDER BY item_count DESC
INTO TEMP top_orders;
SELECT * FROM orders WHERE order_id IN (SELECT order_id FROM top_orders);
Diagnostic Checks
- Scan the statement for
FIRST/LIMIT/SKIPappearing inside a subquery rather than the outerSELECT.
Related Errors / Related Topics
No closely related error codes are cross-referenced for -944 in this set yet.
FIRST/LIMIT/SKIP only work on the outer query — materialize a limited subquery's result
into a temp table first if row-limiting is needed there.