Home | Previous Page | Next Page   Function Descriptions >

mi_exec( )

The mi_exec( ) function sends an SQL statement to the database server for parsing, optimization, and execution.

Syntax

mi_integer mi_exec(conn, stmt_strng, control)
   MI_CONNECTION *conn;
   const mi_string *stmt_strng;
   mi_integer control;
conn
is a pointer to a connection descriptor established by a previous call to mi_open( ), mi_server_connect( ), or mi_server_reconnect( ).
stmt_strng
is a pointer to the statement string that contains the text of the SQL statement to execute.
control
is a bit mask of flags that determines the control mode for any results that the executed SQL statement returns. The valid control flags follow:
MI_QUERY_BINARY
The query results are in binary representation rather than text strings.
MI_QUERY_NORMAL
The query results are in text representation (null-terminated strings).
Valid in Client LIBMI Application? Valid in User-Defined Routine?
Yes Yes

Usage

The mi_exec( ) function performs the following tasks:

Tip:
The mi_exec( ) function does not handle execution of prepared statements. To send prepared statements to the database server, use mi_exec_prepared_statement( ) or mi_open_prepared_statement( ).

The mi_exec( ) function only sends the statement; it does not return results to the DataBlade API module. To get results after the execution of mi_exec( ), the DataBlade API module needs to execute the mi_get_result( ) function in a loop.

The current statement must finish before the database server can process the next statement. The mi_query_finish( ) function can be used to force a statement to finish processing. It is strongly advised that you use either mi_query_finish( ) or an mi_get_result( ) loop after each mi_exec( ) function.

Important:
Do not use a handle returned by the mi_get_session_connection( ) function in a call to the mi_exec( ) function. You need to use mi_lo_open( ) to obtain a handle.

For general information about how to send statements with mi_exec( ), see the IBM Informix: DataBlade API Programmer's Guide.

Return Values

MI_OK
indicates that the function was successful.
MI_ERROR
indicates that the function was not successful.

A successful return indicates only that the connection is valid and the statement was successfully executed (for statements other than SELECT) or a cursor was successfully opened (for SELECT). It does not indicate the success of the SQL statement. Use mi_get_result( ) to determine the success of the SQL statement.

Related Topics

See also the descriptions of mi_command_is_finished( ), mi_exec_prepared_statement( ), mi_get_result( ), mi_open_prepared_statement( ), and mi_query_finish( ).

Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]