MySQL Connector/C++ 9.1.0
MySQL connector library for C and C++ applications
Functions
SQL execution

Functions

mysqlx_result_tmysqlx_sql (mysqlx_session_t *sess, const char *query, size_t query_len)
 Execute a plain SQL query. More...
 
mysqlx_result_tmysqlx_sql_param (mysqlx_session_t *sess, const char *query, size_t query_len,...)
 Execute a plain SQL query with parameters. More...
 
mysqlx_stmt_tmysqlx_sql_new (mysqlx_session_t *sess, const char *query, uint32_t length)
 Create a statement which executes a plain SQL query. More...
 

Detailed Description

Function Documentation

◆ mysqlx_sql()

mysqlx_result_t * mysqlx_sql ( mysqlx_session_t sess,
const char *  query,
size_t  query_len 
)

Execute a plain SQL query.

Parameters
sesssession handle
querySQL query
query_lenlength of the query. For NULL-terminated query strings MYSQLX_NULL_TERMINATED can be specified instead of the actual length
Returns
handle to the query results. NULL is returned only in case of an error. The error details can be obtained using mysqlx_error() function

◆ mysqlx_sql_param()

mysqlx_result_t * mysqlx_sql_param ( mysqlx_session_t sess,
const char *  query,
size_t  query_len,
  ... 
)

Execute a plain SQL query with parameters.

Parameters
sesssession handle
querySQL query
query_lenlength of the query. For NULL-terminated query strings MYSQLX_NULL_TERMINATED can be specified instead of the actual length
...variable parameters list consisting of (type, value) pairs terminated by PARAM_END: type_id1, value1, type_id2, value2, ..., 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. Allowed types are listed in mysqlx_data_type_t enum. The X DevAPI for C defines the convenience macros that help to specify the types and values: See PARAM_SINT(), PARAM_UINT(), PARAM_FLOAT(), PARAM_DOUBLE(), PARAM_BYTES(), PARAM_STRING().

Returns
handle to the query results. NULL is returned only in case of an error. The error details can be obtained using mysqlx_error() function

◆ mysqlx_sql_new()

mysqlx_stmt_t * mysqlx_sql_new ( mysqlx_session_t sess,
const char *  query,
uint32_t  length 
)

Create a statement which executes a plain SQL query.

Note
The query can contain ? placeholders whose values should be specified using mysqlx_stmt_bind() function before executing the statement.
Parameters
sesssession handle
querySQL query
lengthlength of the query
Returns
statement handle containing the results and/or error. NULL can be returned only in case when there are problems allocating memory, which normally should not happen. It is very unlikely for this function to end with an error because it does not do any parsing, parameter checking etc.
Note
To actually execute the SQL query the returned statement has to be given to mysqlx_execute().
See also
mysqlx_stmt_bind()