(mysql.info) mysql-stmt-attr-set
Info Catalog
(mysql.info) mysql-stmt-attr-get
(mysql.info) c-api-prepared-statement-functions
(mysql.info) mysql-stmt-bind-param
22.2.7.3 `mysql_stmt_attr_set()'
................................
`int mysql_stmt_attr_set(MYSQL_STMT *stmt, enum enum_stmt_attr_type
option, const void *arg)'
*Description*
Can be used to affect behavior for a prepared statement. This function
may be called multiple times to set several options.
The `option' argument is the option that you want to set; the `arg'
argument is the value for the option. If the option is an integer, then
`arg' should point to the value of the integer.
Possible `option' values:
*Option* *Argument *Function*
Type*
`STMT_ATTR_UPDATE_MAX_LENGTH' `my_bool *' If set to 1: Update
metadata
`MYSQL_FIELD->max_length'
in
`mysql_stmt_store_result()'.
`STMT_ATTR_CURSOR_TYPE' `unsigned Type of cursor to open for
long *' statement when
`mysql_stmt_execute()' is
invoked. `*arg' can be
`CURSOR_TYPE_NO_CURSOR'
(the default) or
`CURSOR_TYPE_READ_ONLY'.
`STMT_ATTR_PREFETCH_ROWS' `unsigned Number of rows to fetch
long *' from server at a time when
using a cursor. `*arg'
can be in the range from 1
to the maximum value of
`unsigned long'. The
default is 1.
If you use the `STMT_ATTR_CURSOR_TYPE' option with
`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,
`mysql_stmt_store_result()' is unnecessary, because that function
causes the result set to be buffered on the client side.
The `STMT_ATTR_CURSOR_TYPE' option was added in MySQL 5.0.2. The
`STMT_ATTR_PREFETCH_ROWS' option was added in MySQL 5.0.6.
*Return Values*
`0' if okay. Non-zero if `option' is unknown.
*Errors*
None.
*Example*
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 ... */
Info Catalog
(mysql.info) mysql-stmt-attr-get
(mysql.info) c-api-prepared-statement-functions
(mysql.info) mysql-stmt-bind-param
automatically generated byinfo2html