Closing a statement cursor
For prepared queries (SQL statements that return rows), the statement
descriptor has a cursor associated with it. The scope of this cursor
is from the time it is opened, with mi_exec_prepared_statement() or mi_open_prepared_statement(),
until one of the following events occurs:
- The mi_close_statement() function closes the cursor (explicit cursors only).
- The mi_drop_prepared_statement() function frees the statement descriptor.
- The mi_close() function closes the connection.
- The SQL statement that invoked the C UDR ends. (Server only)
To conserve resources, use the mi_close_statement() function to explicitly
close an explicit cursor once your DataBlade®
API
module no longer needs it. The mi_close_statement() function is the destructor
function for an explicit cursor that is associated with a statement descriptor. That is, it frees
the cursor that the mi_open_prepared_statement() function opens. Until you drop
the prepared statement with mi_drop_prepared_statement(), you can still reopen an
explicit cursor with another call to mi_open_prepared_statement().
Tip: The mi_close_statement() function performs the same basic task for a
DataBlade®
API module as the SQL CLOSE statement
does for the
Informix® ESQL/C application.
The mi_close_statement() function is not the destructor function for an implicit cursor that is associated with a statement descriptor. That is, it does not free the cursor that the mi_exec_prepared_statement() function opens. To close an implicit cursor, use the mi_drop_prepared_statement() function.