mysql_stmt_attr_set — Modifies the behavior of a prepared statement

my_bool mysql_stmt_attr_set(MYSQL_STMT * stmt,
                            enum enum_stmt_attr_type,
                            const void * attr);

Used to modify the behavior of a prepared statement. This function may be called multiple times to set several attributes.

Parameters

STMT_ATTR_UPDATE_MAX_LENGTH

Indicates if mysql_stmt_store_result() will update the max_length value of MYSQL_FIELD structures.

STMT_ATTR_CURSOR_TYPE

Cursor type. Possible values are CURSOR_TYPE_READ_ONLY or default value CURSOR_TYPE_NO_CURSOR.

STMT_ATTR_PREFETCH_ROWS

Number of rows which will be prefetched. The default value is 1.

stmt

A statement handle, which was previously allocated by mysql_stmt_init().

enum_stmt_attr_type

The attribute that you want to set. It can have one of the following values:

attr

The value to assign to the attribute

Return value

Tero on success, non-zero on failure

[Note]

If you use the MYSQL_STMT_ATTR_CURSOR_TYPE option with MYSQL_CURSOR_TYPE_READ_ONLY, a cursor is opened for the statement when you invoke mysql_stmt_execute(). If there is already an open cursor from a previous mysql_stmt_execute() call, it closes the cursor before opening a new one. mysql_stmt_reset() also closes any open cursor before preparing the statement for re-execution. mysql_stmt_free_result() closes any open cursor.

If you open a cursor for a prepared statement it is unnecessary to call mysql_stmt_store_result().

See also

mysql_stmt_attr_set()