C API Prepared Statement Function Descriptions
2202
Return Values
Zero if successful. Nonzero 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 ... */
20.6.10.4.
mysql_stmt_bind_param()
my_bool mysql_stmt_bind_param(MYSQL_STMT *stmt, MYSQL_BIND *bind)
Description
mysql_stmt_bind_param()
is used to bind input data for the parameter markers in the SQL
statement that was passed to
mysql_stmt_prepare()
. It uses
MYSQL_BIND
structures to supply the
data.
bind
is the address of an array of
MYSQL_BIND
structures. The client library expects the array to
contain one element for each
?
parameter marker that is present in the query.
Suppose that you prepare the following statement:
INSERT INTO mytbl VALUES(?,?,?)
When you bind the parameters, the array of
MYSQL_BIND
structures must contain three elements, and
can be declared like this:
MYSQL_BIND bind[3];
Section 20.6.8, “C API Prepared Statement Data Structures”
, describes the members of each
MYSQL_BIND
element and how they should be set to provide input values.
Return Values
Zero if the bind operation was successful. Nonzero if an error occurred.
Errors
•
CR_UNSUPPORTED_PARAM_TYPE
[2944]
The conversion is not supported. Possibly the
buffer_type
value is illegal or is not one of the
supported types.
•
CR_OUT_OF_MEMORY
[2942]
Out of memory.
•
CR_UNKNOWN_ERROR
[2941]
An unknown error occurred.
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...