The mi_exec() function
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
- A pointer to a connection descriptor established by a previous call to mi_open(), mi_server_connect(), or mi_server_reconnect().
- stmt_strng
- A pointer to the statement string that contains the text of the SQL statement to execute.
- control
- A bit mask of flags that determines the control mode for any results
that the executed SQL statement returns. The valid control flags are:
- 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
- Sends the statement string to the database server for parsing, optimization, and execution
- If any rows are to be returned, creates and opens an implicit
cursor, which is read only and sequential
If the SQL statement is not a SELECT statement, the statement is executed. If it is SELECT, mi_exec() automatically creates and opens a cursor for the retrieved rows.
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.
For general information about how to send statements with mi_exec(), see the Informix® DataBlade® API Programmer's Guide.
Return values
- MI_OK
- The function was successful.
- MI_ERROR
- 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.