Bind values for parametrized statements.
This function binds values of either ?
placeholders in an SQL statement or of named parameters that can be used in other statements.
User code must ensure that the number of values in bind is the same as the number of parameters in the query because this is not checked until receiving the query on the server side.
- Parameters
-
stmt | statement handle |
... | variable parameters list, which has different structure for SQL statements that use placeholders and for other statements that use named parameters. |
For SQL statements it is consisting of (type, value) pairs terminated by PARAM_END
: type_id1, value1, type_id2, value2, ..., type_id_n, value_n, PARAM_END
.
For SELECT, INSERT, UPDATE, DELETE, FIND, ADD, MODIFY and REMOVE statements, the parameters come as triplets (param_name, type, value): name1, type_id1, value1, name2, type_id2, value2, ..., name_n, type_id_n, value_n, PARAM_END
(PARAM_END
marks the end of the parameters list).
type_id is the numeric identifier, which helps to determine the type of the value provided as the next parameter. The user code must ensure that type_id corresponds to the actual value type. Otherwise, the value along with and all sequential types and values are most likely to be corrupted.
It is recommended to use PARAM_TTT()
macros to keep the list integrity: PARAM_UINT()
, PARAM_SINT()
, PARAM_FLOAT()
, PARAM_DOUBLE()
, PARAM_STRING()
, PARAM_BYTES()
, PARAM_EXPR()
for different data types instead of (MYSQLX_TYPE_TTT
, value) pairs.
- Returns
RESULT_OK
- on success; RESULT_ERROR
- on error
- Note
- Each new call resets the binds set by the previous call to
mysqlx_stmt_bind()