Informix Error -285
-285 Invalid cursor received by sqlexec.
The cursor that this statement uses has not been properly declared or prepared, or the FREE statement has released it, or an automatic re-prepare has been attempted while opening the cursor but that operation failed, leaving the cursor unavailable. Review the program logic to ensure that the cursor has been declared. If it has, and if the DECLARE statement refers to a statement identifier, check that the referenced statement has been prepared.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-285 is a broader version of the same statement/cursor-lifecycle family as -267 and -258 — the official text lists all the ways a cursor can end up unavailable in one place.
- The cursor was never properly declared or prepared.
FREEreleased it — the same use-after-free theme as -267/-258.- An automatic re-prepare attempted while opening the cursor failed, leaving it unavailable — the same cause -267 describes.
- If the
DECLARErefers to a statement identifier, that identifier's statement was never actuallyPREPAREd.
Solutions / Resolution
- Review program logic to ensure the cursor has actually been declared.
- If the
DECLARErefers to a statement identifier, check that the referenced statement has been prepared — confirmPREPAREran successfully first. - For the
FREE/re-prepare-failure causes, follow -267's guidance — re-prepare or re-declare before reuse.
Examples
DECLARE referencing an unprepared statement identifier
EXEC SQL DECLARE cur1 CURSOR FOR stmt;
/* stmt was never actually PREPAREd — -285 */
EXEC SQL OPEN cur1;
Fix — prepare the statement first:
EXEC SQL PREPARE stmt FROM :query_text;
EXEC SQL DECLARE cur1 CURSOR FOR stmt;
EXEC SQL OPEN cur1;
Diagnostic Checks
- Review the call sequence for a missing
DECLAREorPREPARE. - If
DECLAREreferences a statement identifier, confirmPREPAREactually succeeded for it beforehand. - Check for
FREEcalls followed by continued use, the same as -267/-258.
Related Errors / Related Topics
- -267 — "The cursor has been previously released and is unavailable." The closest sibling — a more specific version of the same general condition this error covers more broadly.
- -258 — "System error - invalid statement id received by the sqlexec process." Another member of the same statement/cursor-lifecycle family.
Check the full sequence: declared, prepared (if via a statement identifier), and not yet freed — this error covers all three ways that chain can break.