The mi_query_finish() function

The mi_query_finish() function finishes execution of the current statement.

Syntax

mi_integer mi_query_finish(conn)
   MI_CONNECTION *conn;
conn
A pointer to a connection descriptor established by a previous call to mi_open(), mi_server_connect(), or mi_server_reconnect().
Valid in client LIBMI application? Valid in user-defined routine?
Yes Yes

Usage

The mi_query_finish() function completes execution of the current statement on the connection that conn references. The current statement is the most recently executed SQL statement sent to the database server on that connection. This function performs the following steps:
  • If the current statement was a query:
    • Process any pending results that were not already processed with calls to mi_next_row().
    • Close any implicit cursor that mi_exec() or mi_exec_prepared_statement() opened to hold the rows.
  • Release the resources for the current statement:
    • Free the implicit statement descriptor that mi_exec() created.
    • Release other resources associated with the SQL statement.

The mi_query_finish() function does not affect prepared statements or calls to DataBlade® API file-access functions. To determine whether the current statement has completed execution, use the mi_command_is_finished() function.

After mi_query_finish() executes, the next iteration of the mi_get_result() function returns a status of MI_NO_MORE_RESULTS.

This function is useful for ensuring that a statement that returns no meaningful results, such as BEGIN WORK, executed successfully.

Return values

MI_OK
The function was successful.
MI_ERROR
The function was not successful, the current statement failed, or no statement is being processed.