Informix Error -4386: There are too many ORDER BY fields in this report. The maximum number is number.
Cause and resolution
There are too many ORDER BY fields in this report. The maximum number is number.
A limit exists on the number of ordering fields. You will have to redesign the report so that it requires ordering by no more than number columns. Alternatively you can order the data before passing it to the report, and specify the EXTERNAL keyword on the ORDER BY statement in the report body. It is generally more efficient to have the database server produce the rows in the correct order (using SELECT...ORDER BY in the cursor that produces the rows).
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-4386 fires when a report's ORDER BY clause exceeds the maximum number of ordering fields —
per the official guidance, this is a hard limit on report-level ordering.
- An
ORDER BYclause with more fields than the report supports, per the official guidance — the direct, only cause.
Solutions / Resolution
- Redesign the report to require ordering by no more than the stated maximum number of columns, per the official guidance.
- Alternatively, order the data before passing it to the report, and specify
EXTERNALon the report'sORDER BY, per the official guidance — generally more efficient, since the database server produces the rows already ordered viaSELECT...ORDER BYin the driving cursor.
Examples
Ordering externally instead
DECLARE cur CURSOR FOR
SELECT * FROM orders ORDER BY region, customer, order_date;
REPORT myreport(rec)
ORDER EXTERNAL BY rec.region, rec.customer, rec.order_date
Diagnostic Checks
- Count the report's
ORDER BYfields against the stated maximum, and either reduce them or move ordering to the driving cursor'sSELECT...ORDER BYwithEXTERNAL.
Related Errors / Related Topics
No closely related error codes are cross-referenced for -4386 in this set yet.
A report's ORDER BY exceeds the field limit — reduce it, or order externally via the driving
cursor's SELECT...ORDER BY.