You can call the mysql_stmt_attr_set() function to set an attribute value for a prepared statement.
Syntax
my_bool
mysql_stmt_attr_set(MYSQL_STMT *stmt,
enum enum_stmt_attr_type option,
const void *arg)
Arguments
option: the option to be set.arg: the value of the option.argshould point to a variable of the desired attribute value. The following table describes the variable types.Option Parameter type Description STMT_ATTR_UPDATE_MAX_LENGTH my_bool * If it is set to 1, it will cause mysql_stmt_store_result()to update the metadataMYSQL_FIELD->max_lengthvalue.STMT_ATTR_CURSOR_TYPE unsigned long * The type of cursor to be opened for the statement when mysql_stmt_execute()is called.*argcan beCURSOR_TYPE_NO_CURSOR(default value) orCURSOR_TYPE_READ_ONLY.STMT_ATTR_PREFETCH_ROWS unsigned long * The number of rows fetched at a time from the server when a cursor is used. *argranges from 1 to the maximum value ofunsigned long. Default value: 1If you use the
STMT_ATTR_CURSOR_TYPEoption together withCURSOR_TYPE_READ_ONLY, a cursor is opened for the statement when you invokemysql_stmt_execute(). If a cursor is already opened from a previousmysql_stmt_execute()call, mysql_stmt_reset() closes the cursor before opening a new one.mysql_stmt_reset()also closes open cursors before preparing a statement for re-execution.mysql_stmt_free_result()can close any open cursor.
Return values
0 is returned for an execution success, and a non-zero value is returned if the option is unknown.
Errors
None.
Notes
You can call the option multiple times to set several options.
If a cursor is opened for a prepared statement, you do not need to call mysql_stmt_store_result(), because that function causes the result set to be buffered on the client.