Informix Error -112
-112 ISAM error: there is no current record.
The ISAM processor has been asked to return the current record, but none has been established. For C-ISAM programs, review the program logic. Before the program uses the ISCURR retrieval mode, it must use another retrieval mode, such as ISFIRST, to establish a current record. If the error recurs, note all circumstances and contact IBM Informix Technical Support.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-112 is more of a genuine program-logic bug than -110/-111 — it means isread() was
called with the ISCURR retrieval mode before any earlier call established what "current" even
refers to. ISCURR asks "give me the record the file is already positioned at"; if nothing has
positioned it yet, there's nothing to return.
ISCURRused as the very first read against a freshly opened file, with no precedingISFIRST,ISLAST,ISEQUAL,ISGREATEQ, or similar positioning call. This is the direct case the official text describes.ISCURRcalled right after a failed prior read. A read that returned an error (-110, -111, or anything else) does not establish a current record — callingISCURRnext has nothing to work with, even though some read attempt did happen just before it.- Position not carried across a close/reopen cycle. Closing and reopening a file resets its
position state; code that assumes the previous handle's "current record" survives into a new
isopen()call is mistaken. - Confusion in multi-file-descriptor code — treating "current record" as shared/global state
when it's actually per-file-descriptor, and issuing
ISCURRagainst a descriptor that never had a positioning call run against it specifically. - A regression from refactoring — code that reorders or restructures retrieval logic and
accidentally drops the initial positioning call that used to run before
ISCURR, without anyone noticing until this error appears. - Positioning invalidated by a delete — depending on the specific behavior in use, deleting
the current record can leave the file without a well-defined "current" position for a
subsequent
ISCURRuntil something repositions it.
Solutions / Resolution
- Always perform an initial positioning read —
ISFIRST,ISLAST,ISEQUAL,ISGREATEQ, or similar — before the firstISCURRcall on a given file descriptor. Review the retrieval logic's call order explicitly rather than assuming it's correct. - Check the return value of every read, including the one meant to establish position. If
that read failed, don't proceed to
ISCURR— there's nothing current to fetch, and the resulting -112 would just be masking the earlier failure. - Re-establish position after every
isclose()/isopen()cycle — never assume position state survives a close, even briefly. - In code juggling multiple file descriptors, track "has positioning happened yet?" per descriptor explicitly, rather than relying on an assumption that it's a single shared state.
- After deleting the current record, check what the specific behavior requires for
continued positioning, and reposition explicitly before another
ISCURRif needed. - When refactoring retrieval code, keep the positioning call and the following
ISCURRcalls visibly paired — consider a helper function that always performs both together, so a future refactor can't separate them without it being obvious.
Examples
The missing initial positioning call
int fd = isopen("customer", ISINPUT);
isread(fd, &record, ISCURR); /* -112: nothing has positioned this file yet */
Correct version:
int fd = isopen("customer", ISINPUT);
isread(fd, &record, ISFIRST); /* establishes position */
/* ... later ... */
isread(fd, &record, ISCURR); /* now valid */
ISCURR after an unchecked failed read
isread(fd, &record, ISEQUAL); /* fails — record doesn't exist, iserrno == -111 */
/* return value not checked */
isread(fd, &record, ISCURR); /* -112: the ISEQUAL failed, so there is no current record */
The real bug is not checking the first call's return value — -112 here is a downstream symptom, not the actual defect.
Lost position across a reopen
int fd = isopen("customer", ISINPUT);
isread(fd, &record, ISEQUAL);
isclose(fd);
fd = isopen("customer", ISINPUT); /* new handle — position from before is gone */
isread(fd, &record, ISCURR); /* -112 */
Position doesn't carry across the close/reopen — the new handle needs its own positioning call.
Diagnostic Checks
- Review the call sequence immediately before the failing
ISCURR— was there a positioning call (ISFIRST/ISLAST/ISEQUAL/ISGREATEQ) on the same file descriptor, and did it succeed? - Check the return code of that prior positioning call explicitly — a failure there, unchecked, is the most common actual root cause behind a -112 that "seems to come from nowhere."
- In multi-descriptor code, confirm which
fdthe failingISCURRtargets and whether positioning was established on that exact descriptor, not just on some other open handle to the same file. - Review recent changes to the retrieval logic — a refactor that reordered or split apart positioning and retrieval calls is a common way to introduce this regression.
Related Errors / Related Topics
- -100 — "ISAM error: duplicate value for a record with unique key." The other foundational ISAM-level error in this family.
- -111 — "ISAM error: no record found." Closely related in practice: a
-111from an unchecked positioning call is one of the most common actual causes of a subsequent-112— check for that sequence first before treating -112 as an isolated problem.
If -112 appears without an obvious missing positioning call in the code you're looking at, check whether the call that should have positioned the file failed silently first — that's the most common real explanation.