Informix Error -4312: The NEED statement is allowed only within reports.
Cause and resolution
The NEED statement is allowed only within reports.
The NEED n LINES statement is used in a report to cause a conditional page skip. This is only relevant in the context of the FORMAT section of a report. Check to see if a REPORT statement has been omitted.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-4312 fires when NEED n LINES appears outside a report's FORMAT section — per the official
guidance, NEED is only relevant for the conditional page skip it triggers within a report's
FORMAT section; check whether a REPORT statement was accidentally omitted.
- A
NEED n LINESstatement used outside any report'sFORMATsection, per the official guidance — the direct, only cause. - A missing
REPORTstatement, per the official guidance — a named reason this might happen unintentionally.
Solutions / Resolution
- Check whether a
REPORTstatement was omitted, per the official guidance. - Move the
NEEDstatement inside a report'sFORMATsection.
Examples
NEED outside a report
FUNCTION printSummary()
NEED 5 LINES
-- -4312: NEED is only valid inside a report's FORMAT section
END FUNCTION
Corrected
REPORT mySummary()
...
FORMAT
ON EVERY ROW
NEED 5 LINES
PRINT ...
END FORMAT
END REPORT
Diagnostic Checks
- Check whether every
NEEDstatement is inside a report'sFORMATsection, and whether aREPORTstatement was accidentally omitted around it.
Related Errors / Related Topics
- -4313 — "The NEED statement cannot be used within report headers or trailers." A related
NEED-usage restriction, about being inside a header/trailer specifically rather than outside a report entirely.
NEED is used outside a report's FORMAT section — move it inside, or check for a missing
REPORT statement.