Send the prepared statement
For a prepared statement to be executed, you must send
it to the database server with one of the following DataBlade®
API functions.
DataBlade® API function | When to use |
---|---|
mi_exec_prepared_statement() | If the prepared statement does not return rows If the prepared statement does return rows but you only need to access these rows sequentially (with an implicit cursor) |
mi_open_prepared_statement() | If the prepared statement does return rows and
you need to perform one of the following tasks:
|
Both these functions support the following parameters.
Parameter | Description |
---|---|
stmt_desc | Is a pointer to a statement descriptor for the
prepared statement The mi_prepare() function generates this statement descriptor. |
control flag | Determines whether any query rows are in binary or text representation |
params_are_binary | Indicates whether the input-parameter values are in binary or text representation |
n_params | Is the number of input-parameter values in the input-parameter-value arrays |
Input-parameter-value arrays:
|
Arrays that contain the following information for
each input-parameter value:
|
retlen | The number of column values that are in each retrieved row |
rettypes | An array that contains the data types of any returned column values |
After the database server executes the prepared statement,
the statement becomes the current statement. The database server sends
back the statement results, including whether the current statement
was successful. Obtain the status of the current statement with the mi_get_result() function.
Tip: The return value that the mi_exec_prepared_statement() or mi_open_prepared_statement() function
returns does not indicate the success of the current statement. It
indicates if mi_exec_prepared_statement() or mi_open_prepared_statement() was
able to successfully send the prepared statement to the database server.