MySQL :: MySQL 8.4 C API Developer Guide :: 6.4.5 mysql_stmt_bind_param() (original) (raw)
The world's most popular open source database
6.4.5 mysql_stmt_bind_param()
bool
mysql_stmt_bind_param(MYSQL_STMT *stmt,
MYSQL_BIND *bind)
Description
mysql_stmt_bind_param() is used to bind input data for the parameter markers in the SQL statement that was passed tomysql_stmt_prepare(). It usesMYSQL_BIND
structures to supply the data.bind
is the address of an array ofMYSQL_BIND
structures. The client library expects the array to contain one element for each?
parameter marker that is present in the query.
Suppose that you prepare the following statement:
INSERT INTO mytbl VALUES(?,?,?)
When you bind the parameters, the array ofMYSQL_BIND
structures must contain three elements, and can be declared like this:
MYSQL_BIND bind[3];
For a description of the members of theMYSQL_BIND
structure and how they should be set to provide input values, seeSection 6.2, “C API Prepared Statement Data Structures”.
Return Values
Zero for success. Nonzero if an error occurred.
Errors
- CR_UNSUPPORTED_PARAM_TYPE
The conversion is not supported. Possibly thebuffer_type
value is invalid or is not one of the supported types. - CR_OUT_OF_MEMORY
Out of memory. - CR_UNKNOWN_ERROR
An unknown error occurred.