my_bool mysql_stmt_attr_set(MYSQL_STMT *stmt, enum
enum_stmt_attr_type option, const void *arg)
Can be used to affect behavior for a prepared statement. This function may be called multiple times to set several options.
option argument is the option that you
want to set. The
arg argument is the value
for the option.
arg should point to a
variable that is set to the desired attribute value. The
variable type is as indicated in the following table.
The following table shows the possible
|If set to 1, causes
|Type of cursor to open for statement when
|Number of rows to fetch from server at a time when using a cursor.
In MySQL 5.0,
unsigned int *, not
STMT_ATTR_UPDATE_MAX_LENGTH. This is
corrected in MySQL 5.1.7.
If you use the
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.
any open cursor.
If you open a cursor for a prepared statement,
unnecessary, because that function causes the result set to be
buffered on the client side.
STMT_ATTR_CURSOR_TYPE option was added in
MySQL 5.0.2. The
option was added in MySQL 5.0.6.
Zero for success. Nonzero if
The following example opens a cursor for a prepared statement and sets the number of rows to fetch at a time to 5:
MYSQL_STMT *stmt; int rc; unsigned long type; unsigned long prefetch_rows = 5; stmt = mysql_stmt_init(mysql); type = (unsigned long) CURSOR_TYPE_READ_ONLY; rc = mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void*) &type); /* ... check return value ... */ rc = mysql_stmt_attr_set(stmt, STMT_ATTR_PREFETCH_ROWS, (void*) &prefetch_rows); /* ... check return value ... */