MySQL Connector/C++ 9.1.0
MySQL connector library for C and C++ applications
Functions | Macros
Statements operating on tables

Functions

mysqlx_result_tmysqlx_table_select (mysqlx_table_t *table, const char *criteria)
 Execute a table SELECT statement with a WHERE clause. More...
 
mysqlx_result_tmysqlx_table_select_limit (mysqlx_table_t *table, const char *criteria, uint64_t row_count, uint64_t offset,...)
 Execute a table SELECT statement with a WHERE, ORDER BY and LIMIT clauses. More...
 
mysqlx_result_tmysqlx_table_insert (mysqlx_table_t *table,...)
 Execute a table INSERT statement with one row. More...
 
mysqlx_result_tmysqlx_table_delete (mysqlx_table_t *table, const char *criteria)
 Execute a table DELETE statement with a WHERE clause. More...
 
mysqlx_result_tmysqlx_table_update (mysqlx_table_t *table, const char *criteria,...)
 Execute a table UPDATE statement. More...
 
mysqlx_stmt_tmysqlx_table_select_new (mysqlx_table_t *table)
 Create a statement which performs a table SELECT operation. More...
 
mysqlx_stmt_tmysqlx_table_insert_new (mysqlx_table_t *table)
 Create a statement executing a table INSERT operation. More...
 
int mysqlx_set_insert_columns (mysqlx_stmt_t *stmt,...)
 Specify column names for an INSERT statement. More...
 
mysqlx_stmt_tmysqlx_table_delete_new (mysqlx_table_t *table)
 Create a statement executing a table DELETE operation. More...
 
mysqlx_stmt_tmysqlx_table_update_new (mysqlx_table_t *table)
 Create a statement executing a table UPDATE operation. More...
 
int mysqlx_set_update_values (mysqlx_stmt_t *stmt,...)
 Set values for the columns in the UPDATE statement. More...
 

Macros

#define mysqlx_set_find_group_by   mysqlx_set_group_by
 A macro defining a function for setting GROUP BY for FIND operation. More...
 
#define mysqlx_set_select_items   mysqlx_set_items
 A macro defining a function for setting projections for SELECT operation. More...
 
#define mysqlx_set_select_where   mysqlx_set_where
 A macro defining a function for setting WHERE for SELECT operation. More...
 
#define mysqlx_set_select_order_by   mysqlx_set_order_by
 A macro defining a function for setting ORDER BY for SELECT operation. More...
 
#define mysqlx_set_select_group_by   mysqlx_set_group_by
 A macro defining a function for setting GROUP BY for SELECT operation. More...
 
#define mysqlx_set_select_limit_and_offset   mysqlx_set_limit_and_offset
 A macro defining a function for setting LIMIT for SELECT operation. More...
 
#define mysqlx_set_delete_where   mysqlx_set_where
 A macro defining a function for setting WHERE clause for DELETE operation. More...
 
#define mysqlx_set_delete_limit(STMT, LIM)   mysqlx_set_limit_and_offset(STMT, LIM, 0)
 A macro defining a function for setting LIMIT for DELETE operation. More...
 
#define mysqlx_set_delete_order_by   mysqlx_set_order_by
 A macro defining a function for setting ORDER BY for DELETE operation. More...
 
#define mysqlx_set_update_where   mysqlx_set_where
 A macro defining a function for setting WHERE clause for UPDATE operation. More...
 
#define mysqlx_set_update_limit(STMT, LIM)   mysqlx_set_limit_and_offset(STMT, LIM, 0)
 A macro defining a function for setting LIMIT for UPDATE operation. More...
 
#define mysqlx_set_update_order_by   mysqlx_set_order_by
 A macro defining a function for setting ORDER BY clause for UPDATE operation. More...
 

Detailed Description

Macro Definition Documentation

◆ mysqlx_set_find_group_by

#define mysqlx_set_find_group_by   mysqlx_set_group_by

A macro defining a function for setting GROUP BY for FIND operation.

See also
mysqlx_set_group_by()

◆ mysqlx_set_select_items

#define mysqlx_set_select_items   mysqlx_set_items

A macro defining a function for setting projections for SELECT operation.

See also
mysqlx_set_items()

◆ mysqlx_set_select_where

#define mysqlx_set_select_where   mysqlx_set_where

A macro defining a function for setting WHERE for SELECT operation.

See also
mysqlx_set_where()

◆ mysqlx_set_select_order_by

#define mysqlx_set_select_order_by   mysqlx_set_order_by

A macro defining a function for setting ORDER BY for SELECT operation.

See also
mysqlx_set_order_by()

◆ mysqlx_set_select_group_by

#define mysqlx_set_select_group_by   mysqlx_set_group_by

A macro defining a function for setting GROUP BY for SELECT operation.

See also
mysqlx_set_group_by()

◆ mysqlx_set_select_limit_and_offset

#define mysqlx_set_select_limit_and_offset   mysqlx_set_limit_and_offset

A macro defining a function for setting LIMIT for SELECT operation.

See also
mysqlx_set_limit_and_offset()

◆ mysqlx_set_delete_where

#define mysqlx_set_delete_where   mysqlx_set_where

A macro defining a function for setting WHERE clause for DELETE operation.

See also
mysqlx_set_where()

◆ mysqlx_set_delete_limit

#define mysqlx_set_delete_limit (   STMT,
  LIM 
)    mysqlx_set_limit_and_offset(STMT, LIM, 0)

A macro defining a function for setting LIMIT for DELETE operation.

See also
mysqlx_set_limit_and_offset()

◆ mysqlx_set_delete_order_by

#define mysqlx_set_delete_order_by   mysqlx_set_order_by

A macro defining a function for setting ORDER BY for DELETE operation.

See also
mysqlx_set_order_by()

◆ mysqlx_set_update_where

#define mysqlx_set_update_where   mysqlx_set_where

A macro defining a function for setting WHERE clause for UPDATE operation.

See also
mysqlx_set_where()

◆ mysqlx_set_update_limit

#define mysqlx_set_update_limit (   STMT,
  LIM 
)    mysqlx_set_limit_and_offset(STMT, LIM, 0)

A macro defining a function for setting LIMIT for UPDATE operation.

See also
mysqlx_set_limit_and_offset()

◆ mysqlx_set_update_order_by

#define mysqlx_set_update_order_by   mysqlx_set_order_by

A macro defining a function for setting ORDER BY clause for UPDATE operation.

See also
mysqlx_set_oder_by()

Function Documentation

◆ mysqlx_table_select()

mysqlx_result_t * mysqlx_table_select ( mysqlx_table_t table,
const char *  criteria 
)

Execute a table SELECT statement with a WHERE clause.

All columns will be selected.

Parameters
tabletable handle
criteriarow selection criteria (WHERE clause); if NULL then all rows in the table are returned.
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_table_select_limit()

mysqlx_result_t * mysqlx_table_select_limit ( mysqlx_table_t table,
const char *  criteria,
uint64_t  row_count,
uint64_t  offset,
  ... 
)

Execute a table SELECT statement with a WHERE, ORDER BY and LIMIT clauses.

Parameters
tabletable handle
criteriarow selection criteria (WHERE clause); if NULL then all rows in the table will be selected.
row_counta number of rows to return (LIMIT clause)
offsetnumber of rows to skip (an offset for the LIMIT clause)
...sorting specification - variable parameters list consisting of (expression, direction) pairs terminated by PARAM_END: expr_1, direction_1, ..., expr_n, direction_n, PARAM_END. Each expression computes a value used to sort the rows/documents in ascending or descending order, as determined by direction constant (TODO: list the direction enum names). Special attention must be paid to the expression strings because the empty string "" or NULL will be treated as the end of sequence
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_table_insert()

mysqlx_result_t * mysqlx_table_insert ( mysqlx_table_t table,
  ... 
)

Execute a table INSERT statement with one row.

Parameters
tabletable handle
...list of column-value specifications consisting of <column_name, value_type, value> triplets. The list should be terminated using PARAM_END. Allowed value 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():

..., "col_uint", PARAM_UINT(uint_val), "col_blob", PARAM_BYTES(byte_buf, buf_len), PARAM_END

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_table_delete()

mysqlx_result_t * mysqlx_table_delete ( mysqlx_table_t table,
const char *  criteria 
)

Execute a table DELETE statement with a WHERE clause.

Parameters
tabletable handle
criteriaexpression selecting rows to be deleted; if this parameter is NULL all rows are deleted
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_table_update()

mysqlx_result_t * mysqlx_table_update ( mysqlx_table_t table,
const char *  criteria,
  ... 
)

Execute a table UPDATE statement.

Parameters
tabletable handle
criteriaexpression selecting rows to be updated (WHERE clause)
...list of column-value specifications consisting of <column_name, value_type, value> triplets. The list should be terminated using PARAM_END. Allowed value 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(), PARAM_EXPR():

..., "col_uint", PARAM_EXPR("col_uint * 100"), "col_blob", PARAM_BYTES(byte_buf, buf_len), PARAM_END

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_table_select_new()

mysqlx_stmt_t * mysqlx_table_select_new ( mysqlx_table_t table)

Create a statement which performs a table SELECT operation.

Parameters
tabletable handle
Returns
handle to the newly created SELECT statement. 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 statement, the returned handle has to be given to mysqlx_execute().
See also
mysqlx_set_insert_columns(), mysqlx_set_insert_row()

◆ mysqlx_table_insert_new()

mysqlx_stmt_t * mysqlx_table_insert_new ( mysqlx_table_t table)

Create a statement executing a table INSERT operation.

Parameters
tabletable handle
Returns
statement handle for the newly created INSERT operation. 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()

◆ mysqlx_set_insert_columns()

int mysqlx_set_insert_columns ( mysqlx_stmt_t stmt,
  ... 
)

Specify column names for an INSERT statement.

The function specifies the names of the columns into which the statement will insert data. User code must ensure that the column values are correct because the names are not validated until receiving the query on the server side after executing with mysqlx_execute().

Parameters
stmtstatement handle
...variable parameters list consisting of column names; the list is terminated by PARAM_END.
Returns
RESULT_OK - on success; RESULT_ERROR - on error
Note
Each new call clears the list of column for a given statement if it was set earlier.
If column names are not specified for an insert statement, it will insert data into all columns of the table.

◆ mysqlx_table_delete_new()

mysqlx_stmt_t * mysqlx_table_delete_new ( mysqlx_table_t table)

Create a statement executing a table DELETE operation.

Parameters
tabletable handle
Returns
handle for the newly created DELETE statement. 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 statement, use mysqlx_execute().
See also
mysqlx_set_delete_where(), mysqlx_set_delete_limit(), mysqlx_set_delete_order_by()

◆ mysqlx_table_update_new()

mysqlx_stmt_t * mysqlx_table_update_new ( mysqlx_table_t table)

Create a statement executing a table UPDATE operation.

Parameters
tabletable handle
Returns
handle for the newly created UPDATE statement. 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 statement, use mysqlx_execute() after specifying what updates should it perform.
See also
mysqlx_set_update_values(), mysqlx_set_update_where(), mysqlx_set_update_limit(), mysqlx_set_update_order_by()

◆ mysqlx_set_update_values()

int mysqlx_set_update_values ( mysqlx_stmt_t stmt,
  ... 
)

Set values for the columns in the UPDATE statement.

Parameters
stmtstatement handle
...variable parameters list consisting of triplets <column_name, value_type, value_or_expression> representing column names, value types and values as expressions. The list is terminated by PARAM_END: column_1, type_1, val_1, ..., column_n, type_n, val_n, PARAM_END. The value type is defined in mysqlx_data_type_t enum. If the value is to be computed on the server side the type has to be set to MYSQLX_TYPE_EXPR. The value (expression) should be specified as a character string expression. For MYSQLX_TYPE_BYTES the function will expect four parameters instead of three as for all other types: <column_name, MYSQLX_TYPE_BYTES, (void*)byte_data, (size_t)length>
Returns
RESULT_OK - on success; RESULT_ERROR - on error
Note
The param list must be not empty, otherwise error is reported.
All fields and their corresponding expressions must be set in one call otherwise the next call to this function will reset all parameters to their new values.