Informix Error -26057: Either statement-id or cursor (%s) is already in use
Cause and resolution
Either statement-id or cursor (%s) is already in use
This error can be returned in either of the following two cases:
Case (1)
Attempt to PREPARE a statement with the same identifier that an earlier PREPARE or DECLARE statement declared, and that has not yet been freed for re-use. Review the program logic, and either FREE this identifier before using it again for this PREPARE statement, or else specify a different identifier.
Example below demonstrates possible way to avoid this error:
PREPARE s_emp FROM "select givenname from employee"; PREPARE s_cust FROM "select fname from customer"; ... FREE s_cust; PREPARE s_cust FROM "select lname from customer"; ... FREE s_cust; FREE s_emp;
Case (2)
Attempt to DECLARE a cursor with the same identifier that an earlier PREPARE or DECLARE statement declared, and that has not yet been freed for re-use. Review the program logic, and either FREE this identifier before using it again for this DECLARE statement, or else specify a different identifier.
Example below demonstrates possible way to avoid this error:
DECLARE c_emp CURSOR FOR s_emp; DECLARE c_cust CURSOR FOR s_cust; ... FREE c_emp; DECLARE c_cust CURSOR FOR s_cust; ... FREE c_cust; FREE c_emp;
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-26057 fires when PREPARE/DECLARE reuses an identifier that's already active — per the
official guidance.
PREPAREused a statement-id an earlierPREPARE/DECLAREalready used, and that hasn't yet beenFREEd, per the official guidance — the first named case.DECLAREused a cursor identifier an earlierPREPARE/DECLAREalready used, and that hasn't yet beenFREEd, per the official guidance — the second named case.
Solutions / Resolution
FREEthe identifier before reusing it, or use a different identifier, per the official guidance.
Examples
Reusing a statement-id without freeing it
PREPARE s_emp FROM "select givenname from employee";
PREPARE s_cust FROM "select fname from customer";
...
FREE s_cust;
PREPARE s_cust FROM "select lname from customer";
...
FREE s_cust;
FREE s_emp;
Diagnostic Checks
- Check the program logic for a
PREPARE/DECLAREreusing an identifier without an interveningFREE, and add the missingFREEor rename the identifier.
Related Errors / Related Topics
- -26055 — "Either statement-id or cursor name (%s) is not defined" The mirror-image error, using an identifier that was never defined rather than reusing one still in use.
A statement-id or cursor identifier was reused without first being FREEd — free it, or use
a different identifier.