Oracle 5.0 Reference Manual page 2229

Table of Contents

Advertisement

If a fetched data value is a
structure contains TRUE (1). Otherwise, the data and its length are returned in the
elements based on the buffer type specified by the application. Each numeric and temporal
*length
type has a fixed length, as listed in the following table. The length of the string types depends on the
length of the actual data value, as indicated by data_length.
Type
MYSQL_TYPE_TINY
MYSQL_TYPE_SHORT
MYSQL_TYPE_LONG
MYSQL_TYPE_LONGLONG
MYSQL_TYPE_FLOAT
MYSQL_TYPE_DOUBLE
MYSQL_TYPE_TIME
MYSQL_TYPE_DATE
MYSQL_TYPE_DATETIME
MYSQL_TYPE_STRING
MYSQL_TYPE_BLOB
In some cases you might want to determine the length of a column value before fetching it with
mysql_stmt_fetch(). For example, the value might be a long string or
want to know how much space must be allocated. To accomplish this, you can use these strategies:
• Before invoking
STMT_ATTR_UPDATE_MAX_LENGTH
mysql_stmt_store_result()
the
STMT_ATTR_UPDATE_MAX_LENGTH
values to be indicated by the
mysql_stmt_result_metadata().
• Invoke
mysql_stmt_fetch()
which the real length can be stored. Then use the real length with mysql_stmt_fetch_column().
real_length= 0;
bind[0].buffer= 0;
bind[0].buffer_length= 0;
bind[0].length= &real_length
mysql_stmt_bind_result(stmt, bind);
mysql_stmt_fetch(stmt);
if (real_length > 0)
{
data= malloc(real_length);
bind[0].buffer= data;
bind[0].buffer_length= real_length;
mysql_stmt_fetch_column(stmt, bind, 0, 0);
}
Return Values
Return Value
0
1
MYSQL_NO_DATA
MYSQL_DATA_TRUNCATED
C API Prepared Statement Function Descriptions
value, the
NULL
mysql_stmt_fetch()
to mysql_stmt_attr_set(), then invoke
to buffer the entire result on the client side. Setting
max_length
with a zero-length buffer for the column in question and a pointer in
Description
Successful, the data has been fetched to application data buffers.
Error occurred. Error code and message can be obtained by
calling
No more rows/data exists
Data truncation occurred
value of the corresponding
*is_null
Length
1
2
4
8
4
8
sizeof(MYSQL_TIME)
sizeof(MYSQL_TIME)
sizeof(MYSQL_TIME)
data length
data_length
to retrieve individual rows, pass
attribute causes the maximal length of column
member of the result set metadata returned by
mysql_stmt_errno()
2209
MYSQL_BIND
*buffer
value for which you
BLOB
and mysql_stmt_error().
and

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents