C API Prepared Statement Data Structures
2193
in place of the corresponding parameter marker in the statement (specified with
?
in the statement
string).
For output,
buffer
is a pointer to the variable in which to return a result set column value. When
you call
mysql_stmt_fetch()
, MySQL stores a column value from the current row of the result
set in this variable. You can access the value when the call returns.
To minimize the need for MySQL to perform type conversions between C language values on the
client side and SQL values on the server side, use C variables that have types similar to those of
the corresponding SQL values:
• For numeric data types,
buffer
should point to a variable of the proper numeric C type.
For integer variables (which can be
char
for single-byte values or an integer type for larger
values), you should also indicate whether the variable has the
unsigned
attribute by setting the
is_unsigned
member, described later.
• For character (nonbinary) and binary string data types,
buffer
should point to a character
buffer.
• For date and time data types,
buffer
should point to a
MYSQL_TIME
structure.
For guidelines about mapping between C types and SQL types and notes about type conversions,
see
Section 20.6.8.1, “C API Prepared Statement Type Codes”
, and
Section 20.6.8.2, “C API
Prepared Statement Type Conversions”
.
•
unsigned long buffer_length
The actual size of
*buffer
in bytes. This indicates the maximum amount of data that can be
stored in the buffer. For character and binary C data, the
buffer_length
value specifies the
length of
*buffer
when used with
mysql_stmt_bind_param()
to specify input values, or
the maximum number of output data bytes that can be fetched into the buffer when used with
mysql_stmt_bind_result()
.
•
unsigned long *length
A pointer to an
unsigned long
variable that indicates the actual number of bytes of data stored
in
*buffer
.
length
is used for character or binary C data.
For input parameter data binding, set
*length
to indicate the actual length of the parameter value
stored in
*buffer
. This is used by
mysql_stmt_execute()
.
For output value binding, MySQL sets
*length
when you call
mysql_stmt_fetch()
. The
mysql_stmt_fetch()
return value determines how to interpret the length:
• If the return value is 0,
*length
indicates the actual length of the parameter value.
• If the return value is
MYSQL_DATA_TRUNCATED
,
*length
indicates the nontruncated length of
the parameter value. In this case, the minimum of
*length
and
buffer_length
indicates the
actual length of the value.
length
is ignored for numeric and temporal data types because the
buffer_type
value
determines the length of the data value.
If you must determine the length of a returned value before fetching it, see
Section 20.6.10.11,
“
mysql_stmt_fetch()
”
, for some strategies.
•
my_bool *is_null
This member points to a
my_bool
variable that is true if a value is
NULL
, false if it is not
NULL
.
For input, set
*is_null
to true to indicate that you are passing a
NULL
value as a statement
parameter.
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 ...