Using End of Transaction to Close a Cursor
The COMMIT WORK and ROLLBACK WORK statements close all cursors except those that are declared with a hold. It is better to close all cursors explicitly, however. For Select or Function cursors, this action simply makes the intent of the program clear. It also helps to avoid a logic error if the WITH HOLD clause is later added to the declaration of a cursor.
For an Insert cursor in ESQL/C routines, it is important to use the CLOSE statement explicitly so that you can test the error code. Following the COMMIT WORK statement, SQLCODE reflects the result of the COMMIT statement, not the result of closing cursors. If you use a COMMIT WORK statement without first using a CLOSE statement, and if an error occurs while the last buffered rows are being written to the database, the transaction is still committed.
For how to use Insert cursors and the WITH HOLD clause, see DECLARE statement.
In an ANSI-compliant database, a cursor cannot be closed implicitly. You must issue the CLOSE statement.