Mstdlib-1.24.0
SQL Statement Request Parameter Binding

Functions

void M_sql_stmt_bind_clear (M_sql_stmt_t *stmt)
 
void M_sql_stmt_bind_clear_row (M_sql_stmt_t *stmt)
 
void M_sql_stmt_bind_new_row (M_sql_stmt_t *stmt)
 
M_sql_error_t M_sql_stmt_bind_bool (M_sql_stmt_t *stmt, M_bool val)
 
M_sql_error_t M_sql_stmt_bind_bool_null (M_sql_stmt_t *stmt)
 
M_sql_error_t M_sql_stmt_bind_int16 (M_sql_stmt_t *stmt, M_int16 val)
 
M_sql_error_t M_sql_stmt_bind_int16_null (M_sql_stmt_t *stmt)
 
M_sql_error_t M_sql_stmt_bind_int32 (M_sql_stmt_t *stmt, M_int32 val)
 
M_sql_error_t M_sql_stmt_bind_int32_null (M_sql_stmt_t *stmt)
 
M_sql_error_t M_sql_stmt_bind_int64 (M_sql_stmt_t *stmt, M_int64 val)
 
M_sql_error_t M_sql_stmt_bind_int64_null (M_sql_stmt_t *stmt)
 
M_sql_error_t M_sql_stmt_bind_text_const (M_sql_stmt_t *stmt, const char *text, size_t max_len)
 
M_sql_error_t M_sql_stmt_bind_text_own (M_sql_stmt_t *stmt, char *text, size_t max_len)
 
M_sql_error_t M_sql_stmt_bind_text_dup (M_sql_stmt_t *stmt, const char *text, size_t max_len)
 
M_sql_error_t M_sql_stmt_bind_binary_const (M_sql_stmt_t *stmt, const M_uint8 *bin, size_t bin_len)
 
M_sql_error_t M_sql_stmt_bind_binary_own (M_sql_stmt_t *stmt, M_uint8 *bin, size_t bin_len)
 
M_sql_error_t M_sql_stmt_bind_binary_dup (M_sql_stmt_t *stmt, const M_uint8 *bin, size_t bin_len)
 

Detailed Description

SQL Statement Parameter Binding

Function Documentation

◆ M_sql_stmt_bind_clear()

void M_sql_stmt_bind_clear ( M_sql_stmt_t stmt)

Clear all bound parameters from a prepared statement object.

Parameters
[in]stmtInitialized M_sql_stmt_t object

◆ M_sql_stmt_bind_clear_row()

void M_sql_stmt_bind_clear_row ( M_sql_stmt_t stmt)

Clear current row bound parameters for prepared statement object. This can be used if the caller wants to cancel the current row parameters due to an internal condition.

Parameters
[in]stmtInitialized M_sql_stmt_t object

◆ M_sql_stmt_bind_new_row()

void M_sql_stmt_bind_new_row ( M_sql_stmt_t stmt)

Increment to next row for statement binding.

Callers can bind multiple rows for insert statements to reduce server round trips during bulk data insertion. This function creates a new row and resets the current column index for binding a new row worth of columns.

All rows must contain the same number of columns consisting of the same data types (with the exception that NULL may be used) or it is considered a failure.

TODO: It may not be possible to determine which row caused a failure, such as a key conflict. Figure this out.

Parameters
[in]stmtInitialized M_sql_stmt_t object

◆ M_sql_stmt_bind_bool()

M_sql_error_t M_sql_stmt_bind_bool ( M_sql_stmt_t stmt,
M_bool  val 
)

Bind M_bool as next column to prepared statement handle

Parameters
[in]stmtInitialized M_sql_stmt_t object
[in]valBoolean value to bind.
Returns
M_SQL_ERROR_SUCCESS on success, or one of the M_sql_error_t values on failure.

◆ M_sql_stmt_bind_bool_null()

M_sql_error_t M_sql_stmt_bind_bool_null ( M_sql_stmt_t stmt)

Bind M_bool NULL column to prepared statement handle

Due to quirks with ODBC, you must know the data type of the bound parameter when binding NULL values.

Parameters
[in]stmtInitialized M_sql_stmt_t object
Returns
M_SQL_ERROR_SUCCESS on success, or one of the M_sql_error_t values on failure.

◆ M_sql_stmt_bind_int16()

M_sql_error_t M_sql_stmt_bind_int16 ( M_sql_stmt_t stmt,
M_int16  val 
)

Bind M_int16 as next column to prepared statement handle

Parameters
[in]stmtInitialized M_sql_stmt_t object
[in]val16bit signed integer value to bind.
Returns
M_SQL_ERROR_SUCCESS on success, or one of the M_sql_error_t values on failure.

◆ M_sql_stmt_bind_int16_null()

M_sql_error_t M_sql_stmt_bind_int16_null ( M_sql_stmt_t stmt)

Bind M_int16 NULL column to prepared statement handle

Due to quirks with ODBC, you must know the data type of the bound parameter when binding NULL values.

Parameters
[in]stmtInitialized M_sql_stmt_t object
Returns
M_SQL_ERROR_SUCCESS on success, or one of the M_sql_error_t values on failure.

◆ M_sql_stmt_bind_int32()

M_sql_error_t M_sql_stmt_bind_int32 ( M_sql_stmt_t stmt,
M_int32  val 
)

Bind M_int32 as next column to prepared statement handle

Parameters
[in]stmtInitialized M_sql_stmt_t object
[in]val32bit signed integer value to bind.
Returns
M_SQL_ERROR_SUCCESS on success, or one of the M_sql_error_t values on failure.

◆ M_sql_stmt_bind_int32_null()

M_sql_error_t M_sql_stmt_bind_int32_null ( M_sql_stmt_t stmt)

Bind M_int32 NULL column to prepared statement handle

Due to quirks with ODBC, you must know the data type of the bound parameter when binding NULL values.

Parameters
[in]stmtInitialized M_sql_stmt_t object
Returns
M_SQL_ERROR_SUCCESS on success, or one of the M_sql_error_t values on failure.

◆ M_sql_stmt_bind_int64()

M_sql_error_t M_sql_stmt_bind_int64 ( M_sql_stmt_t stmt,
M_int64  val 
)

Bind M_int64 as next column to prepared statement handle

Parameters
[in]stmtInitialized M_sql_stmt_t object
[in]val64bit signed integer value to bind.
Returns
M_SQL_ERROR_SUCCESS on success, or one of the M_sql_error_t values on failure.

◆ M_sql_stmt_bind_int64_null()

M_sql_error_t M_sql_stmt_bind_int64_null ( M_sql_stmt_t stmt)

Bind M_int64 NULL column to prepared statement handle

Due to quirks with ODBC, you must know the data type of the bound parameter when binding NULL values.

Parameters
[in]stmtInitialized M_sql_stmt_t object
Returns
M_SQL_ERROR_SUCCESS on success, or one of the M_sql_error_t values on failure.

◆ M_sql_stmt_bind_text_const()

M_sql_error_t M_sql_stmt_bind_text_const ( M_sql_stmt_t stmt,
const char *  text,
size_t  max_len 
)

Bind a const string/text as next column to prepared statement handle

Parameters
[in]stmtInitialized M_sql_stmt_t object
[in]textConstant string, that is guaranteed to be available until the statement is executed, to bind to statement. Pass NULL for a NULL value.
[in]max_lenMaximum length of text/string value to use, use 0 for no maximum.
Returns
M_SQL_ERROR_SUCCESS on success, or one of the M_sql_error_t values on failure.

◆ M_sql_stmt_bind_text_own()

M_sql_error_t M_sql_stmt_bind_text_own ( M_sql_stmt_t stmt,
char *  text,
size_t  max_len 
)

Bind string/text as next column to prepared statement handle that will be automatically freed upon statement destruction.

Parameters
[in]stmtInitialized M_sql_stmt_t object
[in]textPointer to text/string to bind to statement. Must not be free'd by caller as destruction of the prepared statement handle will automatically free the value.
[in]max_lenMaximum length of text/string value to use, use 0 for no maximum.
Returns
M_SQL_ERROR_SUCCESS on success, or one of the M_sql_error_t values on failure.

◆ M_sql_stmt_bind_text_dup()

M_sql_error_t M_sql_stmt_bind_text_dup ( M_sql_stmt_t stmt,
const char *  text,
size_t  max_len 
)

Bind string/text as next column to prepared statement handle that will be duplicated internally as the caller cannot guarantee the pointer will survive after execution of this bind call.

Parameters
[in]stmtInitialized M_sql_stmt_t object
[in]textPointer to text/string that will be duplicated and bound to the statement handle.
[in]max_lenMaximum length of text/string value to use, use 0 for no maximum.
Returns
M_SQL_ERROR_SUCCESS on success, or one of the M_sql_error_t values on failure.

◆ M_sql_stmt_bind_binary_const()

M_sql_error_t M_sql_stmt_bind_binary_const ( M_sql_stmt_t stmt,
const M_uint8 *  bin,
size_t  bin_len 
)

Bind a const binary buffer as next column to prepared statement handle

Parameters
[in]stmtInitialized M_sql_stmt_t object
[in]binConstant binary data, that is guaranteed to be available until the statement is executed, to bind to statement. Pass NULL for a NULL value.
[in]bin_lenLength of binary value to use. Only values up to 64k are allowed.
Returns
M_SQL_ERROR_SUCCESS on success, or one of the M_sql_error_t values on failure.

◆ M_sql_stmt_bind_binary_own()

M_sql_error_t M_sql_stmt_bind_binary_own ( M_sql_stmt_t stmt,
M_uint8 *  bin,
size_t  bin_len 
)

Bind binary buffer as next column to prepared statement handle that will be automatically freed upon statement destruction.

Parameters
[in]stmtInitialized M_sql_stmt_t object
[in]binPointer to binary data to bind to statement. Must not be free'd by caller as destruction of the prepared statement handle will automatically free the value.
[in]bin_lenLength of binary value to use. Only values up to 64k are allowed.
Returns
M_SQL_ERROR_SUCCESS on success, or one of the M_sql_error_t values on failure.

◆ M_sql_stmt_bind_binary_dup()

M_sql_error_t M_sql_stmt_bind_binary_dup ( M_sql_stmt_t stmt,
const M_uint8 *  bin,
size_t  bin_len 
)

Bind binary data as next column to prepared statement handle that will be duplicated internally as the caller cannot guarantee the pointer will survive after execution of this bind call.

Parameters
[in]stmtInitialized M_sql_stmt_t object
[in]binPointer to binary data that will be duplicated and bound to the statement handle.
[in]bin_lenLength of binary value to use. Only values up to 64k are allowed.
Returns
M_SQL_ERROR_SUCCESS on success, or one of the M_sql_error_t values on failure.