Informix Error -482
-482 Invalid operation on a non-SCROLL cursor.
You cannot issue a FETCH PRIOR, FETCH FIRST, FETCH LAST, FETCH CURRENT, FETCH RELATIVE n, or FETCH ABSOLUTE n statement with a non-scroll cursor. To do so, you must first declare the cursor as a scroll cursor.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-482 fires when a FETCH operation requiring bidirectional or positional movement (PRIOR,
FIRST, LAST, CURRENT, RELATIVE n, or ABSOLUTE n) is attempted on a cursor that wasn't
declared with SCROLL — an ordinary (non-scroll) cursor only supports moving forward one row at
a time via plain FETCH/FETCH NEXT.
- A cursor declared without
SCROLL, later used withFETCH PRIOR/FIRST/LAST/RELATIVE/ABSOLUTE— the direct, only cause. - Code copied from a context using scroll cursors, applied to a cursor that wasn't declared with that capability.
- Assuming all cursors support bidirectional movement by default, when it actually requires an explicit declaration.
Solutions / Resolution
- Declare the cursor as a scroll cursor, per the official guidance, before executing these
fetch variants:
DECLARE curs1 SCROLL CURSOR FOR SELECT * FROM orders; - If only forward-only, sequential access is actually needed, use plain
FETCH/FETCH NEXTinstead, and skip theSCROLLdeclaration (which does carry some overhead) entirely.
Examples
Declaring a scroll cursor for bidirectional access
DECLARE curs1 SCROLL CURSOR FOR SELECT * FROM orders;
OPEN curs1;
FETCH FIRST curs1;
FETCH LAST curs1;
FETCH PRIOR curs1;
The disallowed attempt on a non-scroll cursor
DECLARE curs1 CURSOR FOR SELECT * FROM orders;
OPEN curs1;
FETCH FIRST curs1;
-- -482: curs1 wasn't declared with SCROLL
Diagnostic Checks
- Check the cursor's
DECLAREstatement for theSCROLLkeyword. - Confirm the specific
FETCHvariant being used actually requires scroll capability (PRIOR,FIRST,LAST,CURRENT,RELATIVE,ABSOLUTEdo; plainFETCH/FETCH NEXTdon't).
Related Errors / Related Topics
- -423 — "A FETCH CURRENT was attempted with no current row." A related
FETCH-variant error, about row-positioning state rather than the cursor's scroll capability. - -400 — "Fetch attempted on unopen cursor." A related cursor-lifecycle error, about open/closed state rather than scroll capability.
Declare SCROLL explicitly on any cursor that needs PRIOR/FIRST/LAST/RELATIVE/
ABSOLUTE fetches — it isn't the default, and carries overhead worth reserving for cursors that
genuinely need bidirectional access.