Informix Error -487
-487 A cursor can only be declared as static or dynamic.
The specified SQL statement requires you to declare a cursor as static or dynamic. Declare the cursor as static or dynamic, depending on which type of cursor is required, and retry the specified operation.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-487 fires when a cursor declaration specifies neither STATIC nor DYNAMIC — one of these two
cursor scrollability categories is required whenever the declaration calls for a specific type,
rather than leaving it ambiguous or specifying something else entirely.
- A cursor declaration missing an explicit
STATIC/DYNAMICqualifier where one is required by the surrounding statement context. - An invalid or misspelled qualifier used in place of
STATIC/DYNAMIC. - Code assuming a default cursor type applies when the specific statement context actually requires one of the two to be stated explicitly.
Solutions / Resolution
- Declare the cursor as either
STATICorDYNAMIC, per the official guidance, choosing whichever type is actually needed, then retry the operation. - Understand the distinction before choosing: a
STATICcursor's result set is fixed atOPENtime, while aDYNAMICcursor can reflect changes made after opening — pick based on the application's actual requirement.
Examples
Declaring a static cursor
DECLARE curs1 STATIC SCROLL CURSOR FOR SELECT * FROM orders;
Declaring a dynamic cursor
DECLARE curs1 DYNAMIC SCROLL CURSOR FOR SELECT * FROM orders;
Diagnostic Checks
- Check the cursor's
DECLAREstatement for a missing or invalidSTATIC/DYNAMICqualifier. - Determine which behavior is actually needed (fixed result set vs. reflecting later changes) to choose the correct qualifier.
Related Errors / Related Topics
- -482 — "Invalid operation on a non-SCROLL cursor." A related cursor-declaration restriction, about scroll capability rather than the static/dynamic distinction.
- -363 — "CURSOR not on SELECT statement." Another cursor-declaration-level restriction, in a different context (underlying statement type).
Choose STATIC or DYNAMIC based on whether the application needs a fixed result set or one
that can reflect changes made after the cursor is opened.