nanodbc
A small C++ wrapper for the native C ODBC API
Loading...
Searching...
No Matches
nanodbc::table_valued_parameter Class Reference

Support for table-valued parameter. More...

#include <nanodbc.h>

Public Member Functions

 table_valued_parameter ()
 Creates a table-valued parameter that is not yet open.
 
 table_valued_parameter (const table_valued_parameter &rhs) noexcept
 Copy constructor.
 
 table_valued_parameter (table_valued_parameter &&rhs) noexcept
 Move constructor.
 
 table_valued_parameter (statement &stmt, short param_index, size_t row_count)
 Creates a table-valued parameter and opens it on the given statement.
 
 ~table_valued_parameter () noexcept
 Closes the parameter, if it is still open.
 
void open (statement &stmt, short param_index, std::size_t row_count)
 Opens the parameter on a statement, ready for values to be bound to it.
 
void close ()
 Finishes the parameter, so the statement can be executed or bound further.
 
template<class T >
void bind (short param_index, T const *values, std::size_t batch_size)
 Binds multiple values.
 
template<class T >
void bind (short param_index, T const *values, std::size_t batch_size, T const *null_sentry)
 Binds multiple values.
 
template<class T >
void bind (short param_index, T const *values, std::size_t batch_size, bool const *nulls)
 Binds multiple values.
 
void bind (short param_index, std::vector< std::vector< uint8_t > > const &values)
 Binds multiple values.
 
void bind (short param_index, std::vector< std::vector< uint8_t > > const &values, bool const *nulls)
 Binds multiple values.
 
void bind (short param_index, std::vector< std::vector< uint8_t > > const &values, uint8_t const *null_sentry)
 Binds multiple values.
 
template<class T , typename = enable_if_character<T>>
void bind_strings (short param_index, T const *values, std::size_t value_size, std::size_t batch_size)
 Binds multiple string values.
 
template<class T , typename = enable_if_string<T>>
void bind_strings (short param_index, std::vector< T > const &values)
 Binds multiple string values.
 
template<std::size_t BatchSize, std::size_t ValueSize, class T , typename = enable_if_character<T>>
void bind_strings (short param_index, T const (&values)[BatchSize][ValueSize])
 Binds multiple string values.
 
template<class T , typename = enable_if_character<T>>
void bind_strings (short param_index, T const *values, std::size_t value_size, std::size_t batch_size, T const *null_sentry)
 Binds multiple string values.
 
template<class T , typename = enable_if_string<T>>
void bind_strings (short param_index, std::vector< T > const &values, typename T::value_type const *null_sentry)
 Binds multiple string values.
 
template<std::size_t BatchSize, std::size_t ValueSize, class T , typename = enable_if_character<T>>
void bind_strings (short param_index, T const (&values)[BatchSize][ValueSize], T const *null_sentry)
 Binds multiple string values.
 
template<class T , typename = enable_if_character<T>>
void bind_strings (short param_index, T const *values, std::size_t value_size, std::size_t batch_size, bool const *nulls)
 Binds multiple string values.
 
template<class T , typename = enable_if_string<T>>
void bind_strings (short param_index, std::vector< T > const &values, bool const *nulls)
 Binds multiple string values.
 
template<std::size_t BatchSize, std::size_t ValueSize, class T , typename = enable_if_character<T>>
void bind_strings (short param_index, T const (&values)[BatchSize][ValueSize], bool const *nulls)
 Binds multiple string values.
 
void bind_null (short param_index)
 Binds a null value to the given column of every row.
 
void describe_parameters (const std::vector< short > &idx, const std::vector< short > &type, const std::vector< unsigned long > &size, const std::vector< short > &scale)
 Sets descriptions for columns of the table-valued parameter.
 
short parameters () const noexcept
 Returns the number of columns in the table valued parameter.
 
unsigned long parameter_size (short param_index) const
 Returns parameter size for indicated column in the TVP.
 
short parameter_scale (short param_index) const
 Returns parameter scale for indicated column in the TVP.
 
short parameter_type (short param_index) const
 Returns parameter type for indicated column in the TVP.
 

Detailed Description

Support for table-valued parameter.

Constructor & Destructor Documentation

◆ table_valued_parameter()

nanodbc::table_valued_parameter::table_valued_parameter ( statement stmt,
short  param_index,
size_t  row_count 
)

Creates a table-valued parameter and opens it on the given statement.

See also
open()

Member Function Documentation

◆ open()

void nanodbc::table_valued_parameter::open ( statement stmt,
short  param_index,
std::size_t  row_count 
)

Opens the parameter on a statement, ready for values to be bound to it.

Only one table-valued parameter may be open on a statement at a time, and it must be closed before other parameters of that statement are bound.

Parameters
stmtThe prepared statement carrying the parameter marker.
param_indexZero-based index of parameter marker (placeholder position).
row_countNumber of rows that will be bound.
Exceptions
database_error

◆ close()

void nanodbc::table_valued_parameter::close ( )

Finishes the parameter, so the statement can be executed or bound further.

Exceptions
database_error

◆ bind_null()

void nanodbc::table_valued_parameter::bind_null ( short  param_index)

Binds a null value to the given column of every row.

Parameters
param_indexZero-based index of the column within the parameter.
Exceptions
database_error

◆ describe_parameters()

void nanodbc::table_valued_parameter::describe_parameters ( const std::vector< short > &  idx,
const std::vector< short > &  type,
const std::vector< unsigned long > &  size,
const std::vector< short > &  scale 
)

Sets descriptions for columns of the table-valued parameter.

Describing a column up front avoids the call to SQLDescribeParam that binding would otherwise make. A description is re-used across binds until the parameter is closed.

Parameters
idxVector of zero-based indices of the columns being described.
typeVector of (short integer) types.
sizeVector of (unsigned long) sizes.
scaleVector of (short integer) decimal precision / scale.
Exceptions
programming_error

The documentation for this class was generated from the following file: