Informix: Is this a bug?
Posted in 2026
Topics: Error Codes & Troubleshooting
Hi again. Looking over some ancient C code (I think I posted about that earlier), I found something that I thought would cause a non-zero SQLCODE, but it doesn't. The code DECLAREs a cursor, OPENs it, FETCHes the first row, CLOSEs the cursor, does some logic using the host variables populated by the FETCH, and then CLOSEs the cursor a second time. It did not OPEN it a second time, so it's doing a CLOSE against a closed cursor. I see error message -259: -259 Cursor not open. The current statement refers to a cursor that has not been opened. Review the logic of the program to see how it failed to execute the OPEN statement before it reached this point. Statements that end transactions (COMMIT WORK and ROLLBACK WORK) also close cursors unless the cursors are declared WITH HOLD. I fully expected to get the -259 SQLCODE when that second close executed but instead, sqlca.sqlcode had a value of 0. I confirmed this via gdb, stepping through line by line. I believe I've seen situations in the past where trying to close a closed cursor did result in -259. If memory serves, the developer in that case had done a COMMIT on a cursor that was not declared WITH HOLD without realizing that COMMIT implicitly closed the cursor. So this case is slightly different in that the code did an explicit CLOSE, but I still would have expected the second explicit CLOSE to generate an error. Thus my question - is this a bug? This is in 14.10, if it matters. Mark ------------------------------ mark collins ------------------------------