Informix Error -4372: The cursor cursor-name has not yet been declared in this program module. It must be declared before it can be used.
Cause and resolution
The cursor cursor-name has not yet been declared in this program module. It must be declared before it can be used.
The name shown appears where the name of a declared cursor or a prepared statement is expected; however, no cursor (or statement) of that name has been declared (or prepared) to this point in the program. Check the spelling of the name. If it is the name you intended, look back in the program to see why it has not been declared. Possibly the DECLARE statement appears in a GLOBALS file that was not included.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-4372 fires when a name expected to be a declared cursor or prepared statement hasn't been
declared/prepared at that point in the program — per the official guidance, this may be a
spelling error, or the DECLARE statement may be in a GLOBALS file that wasn't included.
- A misspelled cursor/prepared-statement name, per the official guidance — the first named cause.
- The
DECLAREstatement is in aGLOBALSfile that wasn't included, per the official guidance — the second named cause.
Solutions / Resolution
- Check the spelling of the name, per the official guidance.
- Look back in the program to see why it hasn't been declared, per the official
guidance — checking whether a
GLOBALSfile containing theDECLAREwas omitted.
Examples
Using a cursor before declaring it
FOREACH cur INTO rec.*
...
END FOREACH
-- -4372: cur was never DECLAREd
Corrected
DECLARE cur CURSOR FOR SELECT * FROM orders;
FOREACH cur INTO rec.*
...
END FOREACH
Diagnostic Checks
- Check the cursor/prepared-statement name's spelling, and confirm its
DECLAREstatement (possibly in aGLOBALSfile) has actually been included.
Related Errors / Related Topics
- -4371 — "Cursors must be uniquely declared within one program module." A related cursor-declaration error, about a duplicate declaration rather than a missing one.
A cursor/prepared-statement name is used before being declared — check its spelling and
whether its DECLARE (possibly in GLOBALS) was included.