C API Prepared Statement Data Structures
2194
is_null
is a pointer to a boolean scalar, not a boolean scalar, to provide flexibility in how you
specify
NULL
values:
• If your data values are always
NULL
, use
MYSQL_TYPE_NULL
as the
buffer_type
value when
you bind the column. The other
MYSQL_BIND
members, including
is_null
, do not matter.
• If your data values are always
NOT NULL
, set
is_null = (my_bool*) 0
, and set the other
members appropriately for the variable you are binding.
• In all other cases, set the other members appropriately and set
is_null
to the address of a
my_bool
variable. Set that variable's value to true or false appropriately between executions to
indicate whether the corresponding data value is
NULL
or
NOT NULL
, respectively.
For output, when you fetch a row, MySQL sets the value pointed to by
is_null
to true or false
according to whether the result set column value returned from the statement is or is not
NULL
.
•
my_bool is_unsigned
This member applies for C variables with data types that can be
unsigned
(
char
,
short
int
,
int
,
long long int
). Set
is_unsigned
to true if the variable pointed to by
buffer
is
unsigned
and false otherwise. For example, if you bind a
signed char
variable to
buffer
,
specify a type code of
MYSQL_TYPE_TINY
and set
is_unsigned
to false. If you bind an
unsigned char
instead, the type code is the same but
is_unsigned
should be true. (For
char
, it is not defined whether it is signed or unsigned, so it is best to be explicit about signedness
by using
signed char
or
unsigned char
.)
is_unsigned
applies only to the C language variable on the client side. It indicates nothing
about the signedness of the corresponding SQL value on the server side. For example, if you use
an
int
variable to supply a value for a
BIGINT UNSIGNED
column,
is_unsigned
should be
false because
int
is a signed type. If you use an
unsigned int
variable to supply a value for
a
BIGINT
column,
is_unsigned
should be true because
unsigned int
is an unsigned type.
MySQL performs the proper conversion between signed and unsigned values in both directions,
although a warning occurs if truncation results.
•
my_bool *error
For output, set this member to point to a
my_bool
variable to have truncation information
for the parameter stored there after a row fetching operation. When truncation reporting is
enabled,
mysql_stmt_fetch()
returns
MYSQL_DATA_TRUNCATED
and
*error
is true in
the
MYSQL_BIND
structures for parameters in which truncation occurred. Truncation indicates
loss of sign or significant digits, or that a string was too long to fit in a column. Truncation
reporting is enabled by default, but can be controlled by calling
mysql_options()
with the
MYSQL_REPORT_DATA_TRUNCATION
option. The
error
member was added in MySQL 5.0.3.
•
MYSQL_TIME
This structure is used to send and receive
DATE
,
TIME
,
DATETIME
, and
TIMESTAMP
data
directly to and from the server. Set the
buffer
member to point to a
MYSQL_TIME
structure,
and set the
buffer_type
member of a
MYSQL_BIND
structure to one of the temporal types
(
MYSQL_TYPE_TIME
,
MYSQL_TYPE_DATE
,
MYSQL_TYPE_DATETIME
,
MYSQL_TYPE_TIMESTAMP
).
The
MYSQL_TIME
structure contains the members listed in the following table.
Member
Description
unsigned int year
The year
unsigned int month
The month of the year
unsigned int day
The day of the month
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 ...