nanodbc
A small C++ wrapper for the native C ODBC API
Loading...
Searching...
No Matches
Reading column values

Reads values from columns of the current rowset. More...

Functions

template<class T >
void nanodbc::result::get_ref (short column, T &result) const
 Gets data from the given column of the current rowset.
 
template<class T >
void nanodbc::result::get_ref (short column, T const &fallback, T &result) const
 Gets data from the given column of the current rowset.
 
template<class T >
void nanodbc::result::get_ref (string const &column_name, T &result) const
 Gets data from the given column by name of the current rowset.
 
template<class T >
void nanodbc::result::get_ref (string const &column_name, T const &fallback, T &result) const
 Gets data from the given column by name of the current rowset.
 
template<class T >
nanodbc::result::get (short column) const
 Gets data from the given column of the current rowset.
 
template<class T >
nanodbc::result::get (short column, T const &fallback) const
 Gets data from the given column of the current rowset.
 
template<class T >
nanodbc::result::get (string const &column_name) const
 Gets data from the given column by name of the current rowset.
 
template<class T >
nanodbc::result::get (string const &column_name, T const &fallback) const
 Gets data from the given column by name of the current rowset.
 

Detailed Description

Reads values from columns of the current rowset.

Attention
When nanodbc is compiled as a library, get() and get_ref() are only available for the types they are explicitly instantiated for in nanodbc.cpp. Using any other type compiles, because the declaration is visible here, but fails to link. The supported types are: bool, signed char, unsigned char, short, unsigned short, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int, float, double, std::string, wide_string, std::string::value_type, wide_string::value_type, date, time, timestamp, timestampoffset and std::vector<std::uint8_t> for binary data. Each is also available wrapped in std::optional where the standard library provides it, and _variant_t on MSVC.

Function Documentation

◆ get_ref() [1/4]

template<class T >
void nanodbc::result::get_ref ( short  column,
T &  result 
) const

Gets data from the given column of the current rowset.

Columns are numbered from left to right and 0-indexed.

Parameters
columnposition.
resultThe column's value will be written to this parameter.
Exceptions
database_error
index_range_error
type_incompatible_error
null_access_error

◆ get_ref() [2/4]

template<class T >
void nanodbc::result::get_ref ( short  column,
T const &  fallback,
T &  result 
) const

Gets data from the given column of the current rowset.

If the data is null, fallback is returned instead.

Columns are numbered from left to right and 0-indexed.

Parameters
columnposition.
fallbackif value is null, return fallback instead.
resultThe column's value will be written to this parameter.
Exceptions
database_error
index_range_error
type_incompatible_error

◆ get_ref() [3/4]

template<class T >
void nanodbc::result::get_ref ( string const &  column_name,
T &  result 
) const

Gets data from the given column by name of the current rowset.

Parameters
column_namecolumn's name.
resultThe column's value will be written to this parameter.
Exceptions
database_error
index_range_error
type_incompatible_error
null_access_error

◆ get_ref() [4/4]

template<class T >
void nanodbc::result::get_ref ( string const &  column_name,
T const &  fallback,
T &  result 
) const

Gets data from the given column by name of the current rowset.

If the data is null, fallback is returned instead.

Parameters
column_namecolumn's name.
fallbackif value is null, return fallback instead.
resultThe column's value will be written to this parameter.
Exceptions
database_error
index_range_error
type_incompatible_error

◆ get() [1/4]

template<class T >
T nanodbc::result::get ( short  column) const

Gets data from the given column of the current rowset.

Columns are numbered from left to right and 0-indexed.

Parameters
columnposition.
Exceptions
database_error
index_range_error
type_incompatible_error
null_access_error

◆ get() [2/4]

template<class T >
T nanodbc::result::get ( short  column,
T const &  fallback 
) const

Gets data from the given column of the current rowset.

If the data is null, fallback is returned instead.

Columns are numbered from left to right and 0-indexed.

Parameters
columnposition.
fallbackif value is null, return fallback instead.
Exceptions
database_error
index_range_error
type_incompatible_error

◆ get() [3/4]

template<class T >
T nanodbc::result::get ( string const &  column_name) const

Gets data from the given column by name of the current rowset.

Parameters
column_namecolumn's name.
Exceptions
database_error
index_range_error
type_incompatible_error
null_access_error

◆ get() [4/4]

template<class T >
T nanodbc::result::get ( string const &  column_name,
T const &  fallback 
) const

Gets data from the given column by name of the current rowset.

If the data is null, fallback is returned instead.

Parameters
column_namecolumn's name.
fallbackif value is null, return fallback instead.
Exceptions
database_error
index_range_error
type_incompatible_error