mysql_stmt_bind_result()

2023-07-26 02:37:19  Updated

You can call the mysql_stmt_bind_result() function to associate or bind output columns in a result set to data buffers and length buffers.

Syntax

my_bool
mysql_stmt_bind_result(MYSQL_STMT *stmt,
                       MYSQL_BIND *bind)

bind is the address of an array of MYSQL_BIND structures.

Return values

0 is returned for an execution success, and a non-zero value is returned if an error occurred.

Errors

  • CR_UNSUPPORTED_PARAM_TYPE: The conversion is not supported. Maybe the buffer_type value is invalid or the type is not supported.

  • CR_OUT_OF_MEMORY: The memory is insufficient.

  • CR_UNKNOWN_ERROR: An unknown error occurred.

Notes

When mysql_stmt_fetch() is called to fetch data, the OceanBase client/server protocol places the data for the bound columns into the specified buffers. Before mysql_stmt_fetch() is called, all columns must be bound to buffers.

The client library expects the array to contain one element for each column of the result set. If a column is not bound to a MYSQL_BIND structure, mysql_stmt_fetch() ignores this column during data fetch.

A column can be bound or rebound at any time, even after a result set is partially retrieved. The new binding takes effect the next time when mysql_stmt_fetch() is called. Assume that an application binds the columns in a result set and calls mysql_stmt_fetch(). The client/server protocol returns data in the bound buffers. Then, assume that the application binds the columns to a different set of buffers. The protocol places data into the newly bound buffers the next time when mysql_stmt_fetch() is called.

To bind a column, the application calls mysql_stmt_bind_result() and passes the type, address, and length of the output buffer.

Contact Us