C API Prepared Statement Function Descriptions
2200
Suppose that you prepare and execute a statement as follows:
1. Call
mysql_stmt_prepare()
to prepare the statement string
"SELECT ?"
.
2. Call
mysql_stmt_bind_param()
to bind the value
3
to the parameter in the prepared statement.
3. Call
mysql_stmt_execute()
to execute the prepared statement.
As a result of the preceding calls, the server writes the following lines to the general query log:
Prepare [1] SELECT ?
Execute [1] SELECT 3
Each
Prepare
and
Execute
line in the log is tagged with a
[N]
statement identifier so that you can
keep track of which prepared statement is being logged.
N
is a positive integer. If there are multiple
prepared statements active simultaneously for the client,
N
may be greater than 1. Each
Execute
lines
shows a prepared statement after substitution of data values for
?
parameters.
20.6.10. C API Prepared Statement Function Descriptions
To prepare and execute queries, use the functions described in detail in the following sections.
All functions that operate with a
MYSQL_STMT
structure begin with the prefix
mysql_stmt_
.
To create a
MYSQL_STMT
handle, use the
mysql_stmt_init()
function.
20.6.10.1.
mysql_stmt_affected_rows()
my_ulonglong mysql_stmt_affected_rows(MYSQL_STMT *stmt)
Description
mysql_stmt_affected_rows()
may be called immediately after executing a statement with
mysql_stmt_execute()
. It is like
mysql_affected_rows()
but for prepared statements. For
a description of what the affected-rows value returned by this function means, See
Section 20.6.6.1,
“
mysql_affected_rows()
”
.
Errors
None.
Example
See the Example in
Section 20.6.10.10, “
mysql_stmt_execute()
”
.
20.6.10.2.
mysql_stmt_attr_get()
my_bool mysql_stmt_attr_get(MYSQL_STMT *stmt, enum enum_stmt_attr_type
option, void *arg)
Description
Can be used to get the current value for a statement attribute.
The
option
argument is the option that you want to get; the
arg
should point to a variable that should
contain the option value. If the option is an integer,
arg
should point to the value of the integer.
See
Section 20.6.10.3, “
mysql_stmt_attr_set()
”
, for a list of options and option types.
Note
In MySQL 5.0,
mysql_stmt_attr_get()
uses
unsigned int *
, not
my_bool *
, for
STMT_ATTR_UPDATE_MAX_LENGTH
. This was corrected in
MySQL 5.1.7.
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 ...