A record that is automatically linked at run time. More...
#include <record.h>
Classes | |
class | bind_info_t |
Structure holding bind information for a dynamically allocated column. More... | |
Public Member Functions | |
const std::string & | column_name (SQLSMALLINT col) const |
Return the name of a column. | |
SQLSMALLINT | column_number (const std::string &name) const |
Return the number of a named column. | |
bool | empty () const |
Check whether the bounds were added to this record. | |
bool | exists (const std::string &name) |
Search for a column by name. | |
void | get (SQLSMALLINT col, SQLGUID &guid) const |
Retrieve a column data as a guid structure. | |
void | get (const std::string &name, SQLGUID &guid) const |
Retrieve a column data as a guid structure. | |
void | get (SQLSMALLINT col, SQL_NUMERIC_STRUCT &numeric) const |
Retrieve a column data as a numeric structure. | |
void | get (const std::string &name, SQL_NUMERIC_STRUCT &numeric) const |
Retrieve a column data as a numeric structure. | |
void | get (SQLSMALLINT col, SQL_TIMESTAMP_STRUCT ×tamp) const |
Retrieve a column data as a timestamp structure. | |
void | get (const std::string &name, SQL_TIMESTAMP_STRUCT ×tamp) const |
Retrieve a column data as a timestamp structure. | |
void | get (SQLSMALLINT col, SQL_TIME_STRUCT &time) const |
Retrieve a column data as a time structure. | |
void | get (const std::string &name, SQL_TIME_STRUCT &time) const |
Retrieve a column data as a time structure. | |
void | get (SQLSMALLINT col, SQL_DATE_STRUCT &date) const |
Retrieve a column data as a date structure. | |
void | get (const std::string &name, SQL_DATE_STRUCT &date) const |
Retrieve a column data as a date structure. | |
SQLULEN | get (SQLSMALLINT col, SQLCHAR *binary, SQLLEN length) const |
Retrieve a column data as a binary buffer. | |
SQLULEN | get (const std::string &name, SQLCHAR *binary, SQLLEN length) const |
Retrieve a column data as a binary buffer. | |
void | get (SQLSMALLINT col, SQLFLOAT &dbl) const |
Retrieve a column data as a float number. | |
void | get (const std::string &name, SQLFLOAT &dbl) const |
Retrieve a column data as a float number. | |
void | get (SQLSMALLINT col, SQLREAL &real) const |
Retrieve a column data as a real number. | |
void | get (const std::string &name, SQLREAL &real) const |
Retrieve a column data as a real number. | |
void | get (SQLSMALLINT col, SQLUBIGINT &big_int) const |
Retrieve a column data as a big integer. | |
void | get (const std::string &name, SQLUBIGINT &big_int) const |
Retrieve a column data as a big integer. | |
void | get (SQLSMALLINT col, SQLBIGINT &big_int) const |
Retrieve a column data as a big integer. | |
void | get (const std::string &name, SQLBIGINT &big_int) const |
Retrieve a column data as a big integer. | |
void | get (SQLSMALLINT col, SQLUINTEGER &integer) const |
Retrieve a column data as an integer. | |
void | get (const std::string &name, SQLUINTEGER &integer) const |
Retrieve a column data as an integer. | |
void | get (SQLSMALLINT col, SQLINTEGER &integer) const |
Retrieve a column data as an integer. | |
void | get (const std::string &name, SQLINTEGER &integer) const |
Retrieve a column data as an integer. | |
void | get (SQLSMALLINT col, SQLUSMALLINT &small_int) const |
Retrieve a column data as a small integer. | |
void | get (const std::string &name, SQLUSMALLINT &small_int) const |
Retrieve a column data as a small integer. | |
void | get (SQLSMALLINT col, SQLSMALLINT &small_int) const |
Retrieve a column data as a small integer. | |
void | get (const std::string &name, SQLSMALLINT &small_int) const |
Retrieve a column data as a small integer. | |
void | get (SQLSMALLINT col, SQLSCHAR &tiny_int) const |
Retrieve a column data as a tiny integer. | |
void | get (const std::string &name, SQLSCHAR &tiny_int) const |
Retrieve a column data as a tiny integer. | |
void | get (SQLSMALLINT col, SQLCHAR &tiny_int) const |
Retrieve a column data as a tiny integer. | |
void | get (const std::string &name, SQLCHAR &tiny_int) const |
Retrieve a column data as a tiny integer. | |
void | get (SQLSMALLINT col, std::wstring &str) const |
Retrieve a column data as a string. | |
void | get (const std::string &name, std::wstring &str) const |
Retrieve a column data as a string. | |
void | get (SQLSMALLINT col, std::string &str) const |
Retrieve a column data as a string. | |
void | get (const std::string &name, std::string &str) const |
Retrieve a column data as a string. | |
SQLSMALLINT | get_decimal_digits (SQLSMALLINT col) const |
Retrieve the number of decimal digits of the column. | |
SQLSMALLINT | get_decimal_digits (const std::string &name) const |
Retrieve the number of decimal digits of the named column. | |
SQLSMALLINT | get_is_null (SQLSMALLINT col) const |
Retrieve the type of the column. | |
SQLSMALLINT | get_is_null (const std::string &name) const |
Check whether the named column is NULL. | |
SQLLEN | get_size (SQLSMALLINT col) const |
Retrieve the size of the column. | |
SQLLEN | get_size (const std::string &name) const |
Retrieve the size of the named column. | |
SQLSMALLINT | get_type (SQLSMALLINT col) const |
Retrieve the type of the column. | |
SQLSMALLINT | get_type (const std::string &name) const |
Retrieve the type of the named column. | |
virtual bool | is_dynamic () const |
Bound all the columns to variables automatically? | |
size_t | size () const |
Return the number of bound records. | |
Private Types | |
typedef std::vector < bind_info_t * > | bind_info_col_vector_t |
A vector of columns to sort them by index. | |
typedef std::map< const std::string, bind_info_t * > | bind_info_name_map_t |
A map that links a column name and the column bind information. | |
typedef std::pair< const std::string, bind_info_t * > | bind_info_name_t |
A pair with the column name and its information. | |
Private Member Functions | |
virtual void | bind_impl () |
Proceed with binding the variables. | |
const bind_info_t * | find_column (SQLSMALLINT col, SQLSMALLINT target_type, bool except_null=false) const |
Search a column by name and check its type. | |
const bind_info_t * | find_column (const std::string &name, SQLSMALLINT target_type, bool except_null=false) const |
Search a column by index and check its type. | |
const bind_info_t * | verify_column (const bind_info_t *info, SQLSMALLINT target_type, bool except_null) const |
Verify that the column matches what the user wants. | |
Private Attributes | |
bind_info_col_vector_t | f_bind_by_col |
Array holding the column binding information by index. | |
bind_info_name_map_t | f_bind_by_name |
Map holding the column binding information by name. |
A record that is automatically linked at run time.
This type of record, you usually do not derive from. It is used to read rows of data from a table of which columns aren't known until run time.
If you do know the columns at the time you compile your code, you may want to consider using the record class instead. It will be a little faster (avoid one copy for most data.)
Definition at line 225 of file record.h.
typedef std::vector<bind_info_t *> odbcpp::dynamic_record::bind_info_col_vector_t [private] |
typedef std::map<const std::string, bind_info_t *> odbcpp::dynamic_record::bind_info_name_map_t [private] |
typedef std::pair<const std::string, bind_info_t *> odbcpp::dynamic_record::bind_info_name_t [private] |
void odbcpp::dynamic_record::bind_impl | ( | ) | [private, virtual] |
Proceed with binding the variables.
This function is the one used to bind a record variables to an ODBC statement.
The following shows what the SQL types are bound with. (=) SQL_<name> and SQL_C_<name> are equal (<>) SQL_<name> and SQL_C_<name> differ and a mapping is necessary We do not make use of SQL_C_DEFAULT at this time. SQL data types C data types SQL_UNKNOWN_TYPE 0 <undefined> SQL_CHAR 1 SQL_C_CHAR (=) SQL_NUMERIC 2 SQL_C_NUMERIC (=, SQL_C_CHAR up to v3.0 and thus <>) SQL_DECIMAL 3 SQL_C_CHAR (<>) SQL_INTEGER 4 SQL_C_LONG (=) SQL_SMALLINT 5 SQL_C_SHORT (=) SQL_FLOAT 6 SQL_C_DOUBLE (<>) SQL_REAL 7 SQL_C_FLOAT (=) SQL_DOUBLE 8 SQL_C_DOUBLE (=) SQL_DATETIME 9 ignore, same as SQL_DATE SQL_DATE 9 SQL_C_DATE (=) SQL_INTERVAL 10 ignore, same as SQL_TIME SQL_TIME 10 SQL_C_TIME (=) SQL_TIMESTAMP 11 SQL_C_TIMESTAMP (=) SQL_VARCHAR 12 SQL_C_CHAR (<>) SQL_TYPE_DATE 91 SQL_C_TYPE_DATE (=) SQL_TYPE_TIME 92 SQL_C_TYPE_TIME (=) SQL_TYPE_TIMESTAMP 93 SQL_C_TYPE_TIMESTAMP (=) SQL_LONGVARCHAR (-1) SQL_C_CHAR (<>) SQL_BINARY (-2) SQL_C_BINARY (=) SQL_VARBINARY (-3) SQL_C_CHAR (<>) SQL_LONGVARBINARY (-4) SQL_C_CHAR (<>) SQL_BIGINT (-5) SQL_C_SBIGINT (<>) SQL_TINYINT (-6) SQL_C_TINYINT (=) SQL_BIT (-7) SQL_C_BIT (=) SQL_WCHAR (-8) SQL_C_WCHAR (=) SQL_WVARCHAR (-9) SQL_C_WCHAR (<>) SQL_WLONGVARCHAR (-10) SQL_C_WCHAR (<>) SQL_GUID (-11) SQL_C_CHAR (<>)
odbcpp_error | A record with no variable will raise an odbcpp_error. |
Implements odbcpp::record_base.
Definition at line 1696 of file record.cpp.
References column_name(), f_bind_by_col, f_bind_by_name, odbcpp::dynamic_record::bind_info_t::f_bind_type, odbcpp::dynamic_record::bind_info_t::f_col, odbcpp::dynamic_record::bind_info_t::f_data, odbcpp::dynamic_record::bind_info_t::f_decimal_digits, odbcpp::dynamic_record::bind_info_t::f_fetch_size, odbcpp::dynamic_record::bind_info_t::f_name, odbcpp::dynamic_record::bind_info_t::f_size, odbcpp::record_base::f_statement, odbcpp::dynamic_record::bind_info_t::f_target_type, and odbcpp::smartptr< T >::reset().
const std::string & odbcpp::dynamic_record::column_name | ( | SQLSMALLINT | col | ) | const |
Return the name of a column.
This function retrieves the name of the specified column. Quite practicle if you do not know the column names.
[in] | col | The column number. |
Definition at line 1673 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_name, and find_column().
Referenced by bind_impl().
SQLSMALLINT odbcpp::dynamic_record::column_number | ( | const std::string & | name | ) | const |
Return the number of a named column.
This function returns the indice of the named column. Quite practicle if you only know the column name but want to access the data many times and thus want to use the indice which is faster.
[in] | name | The name of the column. |
Definition at line 1689 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_col, and find_column().
odbcpp::dynamic_record::empty | ( | ) | const [inline] |
Check whether the bounds were added to this record.
Before a dynamic record is used in a statmenet::fetch(), it is first bound to dynamically allocated variables. This function returns true if these dynamic variables have not yet been allocated.
Definition at line 231 of file record.h.
References f_bind_by_col, and f_bind_by_name.
bool odbcpp::dynamic_record::exists | ( | const std::string & | name | ) |
Search for a column by name.
This function searches for a column using its name. If the column cannot be found, the function returns false.
If you call one of the get() functions with a column name that does not exist, the get() functions will throw an exception.
[in] | name | The name of the column to search for |
Definition at line 1802 of file record.cpp.
References f_bind_by_name.
const dynamic_record::bind_info_t * odbcpp::dynamic_record::find_column | ( | SQLSMALLINT | col, | |
SQLSMALLINT | target_type, | |||
bool | except_null = false | |||
) | const [private] |
Search a column by name and check its type.
This function searches a column using its name.
If the column does not exist, then an exception is thrown.
If the column exists, but does not have the corresponding type, then an exception is thrown.
Set target_type to SQL_UNKNOWN_TYPE to avoid the check of the type.
[in] | col | The number of the column to find |
[in] | target_type | The expected type for the found column |
[in] | except_null | Refuse the column if the data is set to NULL |
odbcpp_error | If the column is missing or has a different type, then this function throws. |
Definition at line 1880 of file record.cpp.
References f_bind_by_col, odbcpp::odbcpp_error::ODBCPP_NOT_FOUND, and verify_column().
const dynamic_record::bind_info_t * odbcpp::dynamic_record::find_column | ( | const std::string & | name, | |
SQLSMALLINT | target_type, | |||
bool | except_null = false | |||
) | const [private] |
Search a column by index and check its type.
This function searches a column using its index.
If the column does not exist, then an exception is thrown. The index is limited between 1 and size().
If the column exists, but does not have the corresponding type, then an exception is thrown.
Set target_type to SQL_UNKNOWN_TYPE to avoid the check of the type.
The except_null
parameter can be set to true to get a column only if the content is not null. This is used internally by all the get() function to avoid returning an invalid value for null columns.
[in] | name | The name of the column to search |
[in] | target_type | The expected type for the found column |
[in] | except_null | Refuse the column if the data is set to NULL |
odbcpp_error | If the column is missing or has a different type, then this function throws. |
Definition at line 1839 of file record.cpp.
References f_bind_by_name, odbcpp::odbcpp_error::ODBCPP_NOT_FOUND, and verify_column().
Referenced by column_name(), column_number(), get(), get_decimal_digits(), get_is_null(), get_size(), and get_type().
void odbcpp::dynamic_record::get | ( | SQLSMALLINT | col, | |
SQLGUID & | guid | |||
) | const |
Retrieve a column data as a guid structure.
This function attempt to retrieve the data of a column as a guid structure. If the column is not a guid structure, then an exception is generated.
[in] | col | The index of the column to retrieve |
[in] | guid | The user guid structure set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2872 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | const std::string & | name, | |
SQLGUID & | guid | |||
) | const |
Retrieve a column data as a guid structure.
This function attempt to retrieve the data of a column as a guid structure. If the column is not a guid structure, then an exception is generated.
[in] | name | The name of the column to retrieve |
[in] | guid | The user guid structure set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2853 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | SQLSMALLINT | col, | |
SQL_NUMERIC_STRUCT & | numeric | |||
) | const |
Retrieve a column data as a numeric structure.
This function attempt to retrieve the data of a column as a numeric structure. If the column is not a numeric structure, then an exception is generated.
[in] | col | The index of the column to retrieve |
[in] | numeric | The user numeric structure set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2834 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | const std::string & | name, | |
SQL_NUMERIC_STRUCT & | numeric | |||
) | const |
Retrieve a column data as a numeric structure.
This function attempt to retrieve the data of a column as a numeric structure. If the column is not a numeric structure, then an exception is generated.
[in] | name | The name of the column to retrieve |
[in] | numeric | The user numeric structure set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2815 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | SQLSMALLINT | col, | |
SQL_TIMESTAMP_STRUCT & | timestamp | |||
) | const |
Retrieve a column data as a timestamp structure.
This function attempt to retrieve the data of a column as a timestamp structure. If the column is not a timestamp structure, then an exception is generated.
[in] | col | The index of the column to retrieve |
[in] | timestamp | The user timestamp structure set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2796 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | const std::string & | name, | |
SQL_TIMESTAMP_STRUCT & | timestamp | |||
) | const |
Retrieve a column data as a timestamp structure.
This function attempt to retrieve the data of a column as a timestamp structure. If the column is not a timestamp structure, then an exception is generated.
[in] | name | The name of the column to retrieve |
[in] | timestamp | The user timestamp structure set to the data |
odbcpp_error | If the column data does not match, this function generates an odbcpp_error exception. |
Definition at line 2777 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | SQLSMALLINT | col, | |
SQL_TIME_STRUCT & | time | |||
) | const |
Retrieve a column data as a time structure.
This function attempt to retrieve the data of a column as a time structure. If the column is not a time structure, then an exception is generated.
[in] | col | The index of the column to retrieve |
[in] | time | The user time structure set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2758 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | const std::string & | name, | |
SQL_TIME_STRUCT & | time | |||
) | const |
Retrieve a column data as a time structure.
This function attempt to retrieve the data of a column as a time structure. If the column is not a time structure, then an exception is generated.
[in] | name | The name of the column to retrieve |
[in] | time | The user time structure set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2739 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | SQLSMALLINT | col, | |
SQL_DATE_STRUCT & | date | |||
) | const |
Retrieve a column data as a date structure.
This function attempt to retrieve the data of a column as a date structure. If the column is not a date structure, then an exception is generated.
[in] | col | The index of the column to retrieve |
[in] | date | The user date structure set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2720 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | const std::string & | name, | |
SQL_DATE_STRUCT & | date | |||
) | const |
Retrieve a column data as a date structure.
This function attempt to retrieve the data of a column as a date structure. If the column is not a date structure, then an exception is generated.
[in] | name | The name of the column to retrieve |
[in] | date | The user date structure set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2701 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
SQLULEN odbcpp::dynamic_record::get | ( | SQLSMALLINT | col, | |
SQLCHAR * | binary, | |||
SQLLEN | length | |||
) | const |
Retrieve a column data as a binary buffer.
This function attempt to retrieve the data of a column as a binary buffer. The type of the column is not checked since any type of data can be viewed as binary data. If you need to make sure that this column is indeed a binary column, use the get_type() function.
The number of bytes copied in the binary buffer may be less than length. Check the return value to know how many bytes were copied in your binary buffer.
[in] | col | The index of the column to retrieve |
[in] | binary | The user binary buffer pointer to copy the data |
[in] | length | The size of the user binary buffer |
odbcpp_error | If the column cannot be found or is null, an odbcpp_error is raised. |
Definition at line 2667 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, odbcpp::dynamic_record::bind_info_t::f_fetch_size, odbcpp::dynamic_record::bind_info_t::f_size, find_column(), odbcpp::odbcpp_error::ODBCPP_INCORRECT_USE, and size().
SQLULEN odbcpp::dynamic_record::get | ( | const std::string & | name, | |
SQLCHAR * | binary, | |||
SQLLEN | length | |||
) | const |
Retrieve a column data as a binary buffer.
This function attempt to retrieve the data of a column as a binary buffer. The type of the column is not checked since any type of data can be viewed as binary data. If you need to make sure that this column is indeed a binary column, use the get_type() function.
The number of bytes copied in the binary buffer may be less than length. Check the return value to know how many bytes were copied in your binary buffer.
[in] | name | The name of the column to retrieve |
[in] | binary | The user binary buffer pointer to copy the data |
[in] | length | The size of the user binary buffer |
odbcpp_error | If the column cannot be found or is null, an odbcpp_error is raised. |
Definition at line 2625 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, odbcpp::dynamic_record::bind_info_t::f_fetch_size, odbcpp::dynamic_record::bind_info_t::f_size, find_column(), odbcpp::odbcpp_error::ODBCPP_INCORRECT_USE, and size().
void odbcpp::dynamic_record::get | ( | SQLSMALLINT | col, | |
SQLFLOAT & | dbl | |||
) | const |
Retrieve a column data as a float number.
This function attempt to retrieve the data of a column as a float number. If the column is not a float number, then an exception is generated.
[in] | col | The index of the column to retrieve |
[in] | dbl | The user float number set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2598 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | const std::string & | name, | |
SQLFLOAT & | dbl | |||
) | const |
Retrieve a column data as a float number.
This function attempt to retrieve the data of a column as a float number. If the column is not a float number, then an exception is generated.
[in] | name | The name of the column to retrieve |
[in] | dbl | The user float number set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2579 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | SQLSMALLINT | col, | |
SQLREAL & | real | |||
) | const |
Retrieve a column data as a real number.
This function attempt to retrieve the data of a column as a real number. If the column is not a real number, then an exception is generated.
[in] | col | The index of the column to retrieve |
[in] | real | The user real number set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2560 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | const std::string & | name, | |
SQLREAL & | real | |||
) | const |
Retrieve a column data as a real number.
This function attempt to retrieve the data of a column as a real number. If the column is not a real number, then an exception is generated.
[in] | name | The name of the column to retrieve |
[in] | real | The user real number set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2541 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | SQLSMALLINT | col, | |
SQLUBIGINT & | big_int | |||
) | const |
Retrieve a column data as a big integer.
This function attempt to retrieve the data of a column as a big integer. If the column is not a big integer, then an exception is generated.
[in] | col | The index of the column to retrieve |
[in] | big_int | The user big integer set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2522 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | const std::string & | name, | |
SQLUBIGINT & | big_int | |||
) | const |
Retrieve a column data as a big integer.
This function attempt to retrieve the data of a column as a big integer. If the column is not a big integer, then an exception is generated.
[in] | name | The name of the column to retrieve |
[in] | big_int | The user big integer set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2503 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | SQLSMALLINT | col, | |
SQLBIGINT & | big_int | |||
) | const |
Retrieve a column data as a big integer.
This function attempt to retrieve the data of a column as a big integer. If the column is not a big integer, then an exception is generated.
[in] | col | The index of the column to retrieve |
[in] | big_int | The user big integer set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2484 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | const std::string & | name, | |
SQLBIGINT & | big_int | |||
) | const |
Retrieve a column data as a big integer.
This function attempt to retrieve the data of a column as a big integer. If the column is not a big integer, then an exception is generated.
[in] | name | The name of the column to retrieve |
[in] | big_int | The user big integer set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2465 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | SQLSMALLINT | col, | |
SQLUINTEGER & | integer | |||
) | const |
Retrieve a column data as an integer.
This function attempt to retrieve the data of a column as an integer. If the column is not an integer, then an exception is generated.
[in] | col | The index of the column to retrieve |
[in] | integer | The user integer set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2446 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | const std::string & | name, | |
SQLUINTEGER & | integer | |||
) | const |
Retrieve a column data as an integer.
This function attempt to retrieve the data of a column as an integer. If the column is not an integer, then an exception is generated.
[in] | name | The name of the column to retrieve |
[in] | integer | The user integer set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2427 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | SQLSMALLINT | col, | |
SQLINTEGER & | integer | |||
) | const |
Retrieve a column data as an integer.
This function attempt to retrieve the data of a column as an integer. If the column is not an integer, then an exception is generated.
[in] | col | The index of the column to retrieve |
[in] | integer | The user integer set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2408 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | const std::string & | name, | |
SQLINTEGER & | integer | |||
) | const |
Retrieve a column data as an integer.
This function attempt to retrieve the data of a column as an integer. If the column is not an integer, then an exception is generated.
[in] | name | The name of the column to retrieve |
[in] | integer | The user integer set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2389 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | SQLSMALLINT | col, | |
SQLUSMALLINT & | small_int | |||
) | const |
Retrieve a column data as a small integer.
This function attempt to retrieve the data of a column as a small integer. If the column is not a small integer, then an exception is generated.
[in] | col | The index of the column to retrieve |
[in] | small_int | The user small integer set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2370 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | const std::string & | name, | |
SQLUSMALLINT & | small_int | |||
) | const |
Retrieve a column data as a small integer.
This function attempt to retrieve the data of a column as a small integer. If the column is not a small integer, then an exception is generated.
[in] | name | The name of the column to retrieve |
[in] | small_int | The user small integer set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2351 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | SQLSMALLINT | col, | |
SQLSMALLINT & | small_int | |||
) | const |
Retrieve a column data as a small integer.
This function attempt to retrieve the data of a column as a small integer. If the column is not a small integer, then an exception is generated.
[in] | col | The index of the column to retrieve |
[in] | small_int | The user small integer set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2332 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | const std::string & | name, | |
SQLSMALLINT & | small_int | |||
) | const |
Retrieve a column data as a small integer.
This function attempt to retrieve the data of a column as a small integer. If the column is not a small integer, then an exception is generated.
[in] | name | The name of the column to retrieve |
[in] | small_int | The user small integer set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2313 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | SQLSMALLINT | col, | |
SQLSCHAR & | tiny_int | |||
) | const |
Retrieve a column data as a tiny integer.
This function attempt to retrieve the data of a column as a tiny integer. If the column is not a tiny integer, then an exception is generated.
[in] | col | The index of the column to retrieve |
[in] | tiny_int | The user tiny integer set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2294 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | const std::string & | name, | |
SQLSCHAR & | tiny_int | |||
) | const |
Retrieve a column data as a tiny integer.
This function attempt to retrieve the data of a column as a tiny integer. If the column is not a tiny integer, then an exception is generated.
[in] | name | The name of the column to retrieve |
[in] | tiny_int | The user tiny integer set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2275 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | SQLSMALLINT | col, | |
SQLCHAR & | tiny_int | |||
) | const |
Retrieve a column data as a tiny integer.
This function attempt to retrieve the data of a column as a tiny integer. If the column is not a tiny integer, then an exception is generated.
[in] | col | The index of the column to retrieve |
[in] | tiny_int | The user tiny integer set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2256 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | const std::string & | name, | |
SQLCHAR & | tiny_int | |||
) | const |
Retrieve a column data as a tiny integer.
This function attempt to retrieve the data of a column as a tiny integer. If the column is not a tiny integer, then an exception is generated.
[in] | name | The name of the column to retrieve |
[in] | tiny_int | The user tiny integer set to the data |
odbcpp_error | If the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2237 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | SQLSMALLINT | col, | |
std::wstring & | str | |||
) | const |
Retrieve a column data as a string.
This function attempt to retrieve the data of a column as a string. If the column is not a string, then an exception is generated.
[in] | col | The index of the column to retrieve |
[in] | str | The user string set to the data |
If | the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2214 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | const std::string & | name, | |
std::wstring & | str | |||
) | const |
Retrieve a column data as a string.
This function attempt to retrieve the data of a column as a string. If the column is not a string, then an exception is generated.
[in] | name | The name of the column to retrieve |
[in] | str | The user string set to the data |
If | the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2191 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | SQLSMALLINT | col, | |
std::string & | str | |||
) | const |
Retrieve a column data as a string.
This function attempt to retrieve the data of a column as a string. If the column is not a string, then an exception is generated.
[in] | col | The index of the column to retrieve |
[in] | str | The user string set to the data |
If | the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2172 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
void odbcpp::dynamic_record::get | ( | const std::string & | name, | |
std::string & | str | |||
) | const |
Retrieve a column data as a string.
This function attempt to retrieve the data of a column as a string. If the column is not a string, then an exception is generated.
[in] | name | The name of the column to retrieve |
[in] | str | The user string set to the data |
If | the column data does not match or is null, this function generates an odbcpp_error exception. |
Definition at line 2153 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_data, and find_column().
SQLSMALLINT odbcpp::dynamic_record::get_decimal_digits | ( | SQLSMALLINT | col | ) | const |
Retrieve the number of decimal digits of the column.
This function searches for the named column and then return its decimal digits (precision and/or scale). This determines the number of digits in the seconds fraction and numerics.
The column number goes from 1 to dynamic_record::size() inclusive.
[in] | col | The number of the column to check |
odbcpp_error | If the column does not exist, this function will throw an error. |
Definition at line 2038 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_decimal_digits, and find_column().
SQLSMALLINT odbcpp::dynamic_record::get_decimal_digits | ( | const std::string & | name | ) | const |
Retrieve the number of decimal digits of the named column.
This function searches for the named column and then return its decimal digits (precision and/or scale). This determines the number of digits in the seconds fraction and numerics.
[in] | name | The name of the column to check |
odbcpp_error | If the named column cannot be found, this function will throw an error. |
Definition at line 2014 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_decimal_digits, and find_column().
SQLSMALLINT odbcpp::dynamic_record::get_is_null | ( | SQLSMALLINT | col | ) | const |
Retrieve the type of the column.
This function searches for the named column and then return true if it is NULL (as defined in the Database.)
The column number goes from 1 to dynamic_record::size() inclusive.
[in] | col | The number of the column to check |
odbcpp_error | If the column does not exist, this function will throw an error. |
Definition at line 2079 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_fetch_size, and find_column().
SQLSMALLINT odbcpp::dynamic_record::get_is_null | ( | const std::string & | name | ) | const |
Check whether the named column is NULL.
This function searches for the named column and then return true if it is NULL (as defined in the Database.)
[in] | name | The name of the column to check |
odbcpp_error | If the named column cannot be found, this function will throw an error. |
Definition at line 2057 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_fetch_size, and find_column().
SQLLEN odbcpp::dynamic_record::get_size | ( | SQLSMALLINT | col | ) | const |
Retrieve the size of the column.
This function searches for the named column and then return its size in bytes. This is useful for any column that has a variable size.
Null terminated strings can have their size set to SQL_NTS.
Columns that are not set (i.e. are NULL) have a size set to SQL_NULL_DATA.
The column number goes from 1 to dynamic_record::size() inclusive.
[in] | col | The number of the column to check |
odbcpp_error | If the column does not exist, this function will throw an error. |
Definition at line 2134 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_fetch_size, and find_column().
SQLLEN odbcpp::dynamic_record::get_size | ( | const std::string & | name | ) | const |
Retrieve the size of the named column.
This function searches for the named column and then return its size in bytes. This is useful for any column that has a variable size.
Null terminated strings can have their size set to SQL_NTS.
Columns that are not set (i.e. are NULL) have a size set to SQL_NULL_DATA.
[in] | name | The name of the column to check |
odbcpp_error | If the named column cannot be found, this function will throw an error. |
Definition at line 2105 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_fetch_size, and find_column().
SQLSMALLINT odbcpp::dynamic_record::get_type | ( | SQLSMALLINT | col | ) | const |
Retrieve the type of the column.
This function searches for the column and then return its type. This gives you a way to dynamically browse all the columns of a dynamic record if you have no clue what these are.
The column number goes from 1 to dynamic_record::size() inclusive.
[in] | col | The number of the column to check |
odbcpp_error | If the column does not exist, this function will throw an error. |
Definition at line 1993 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_target_type, and find_column().
SQLSMALLINT odbcpp::dynamic_record::get_type | ( | const std::string & | name | ) | const |
Retrieve the type of the named column.
This function searches for the named column and then return its type. This gives you a way to dynamically browse all the columns of a dynamic record if you have no clue what these are.
[in] | name | The name of the column to check |
odbcpp_error | If the named column cannot be found, this function will throw an error. |
Definition at line 1969 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_target_type, and find_column().
virtual bool odbcpp::dynamic_record::is_dynamic | ( | ) | const [inline, virtual] |
Bound all the columns to variables automatically?
If this function returns true, then the record will dynamically bound the columns to variables.
Implements odbcpp::record_base.
odbcpp::dynamic_record::size | ( | ) | const [inline] |
Return the number of bound records.
After a successful call to statmenet::fetch(), a dynamic record includes a set of dynamic variables that can be read using the get() functions.
The get() functions accepts the column name or a record index starting at 1 and going up to size() inclusive.
Definition at line 232 of file record.h.
References f_bind_by_col.
Referenced by get().
const dynamic_record::bind_info_t * odbcpp::dynamic_record::verify_column | ( | const bind_info_t * | info, | |
SQLSMALLINT | target_type, | |||
bool | except_null | |||
) | const [private] |
Verify that the column matches what the user wants.
This function is a private function that verifies that the found column has the correct type.
[in] | info | The column information structure |
[in] | target_type | The expected type for the found column |
[in] | except_null | Refuse the column if the data is set to NULL |
odbcpp_error | If the column has a different type or the column cannot be null (i.e. except_null is true), then this function throws. |
Definition at line 1911 of file record.cpp.
References odbcpp::dynamic_record::bind_info_t::f_bind_type, odbcpp::dynamic_record::bind_info_t::f_fetch_size, odbcpp::dynamic_record::bind_info_t::f_name, odbcpp::odbcpp_error::ODBCPP_NO_DATA, and odbcpp::odbcpp_error::ODBCPP_TYPE_MISMATCH.
Referenced by find_column().
odbcpp::dynamic_record::f_bind_by_col [private] |
Array holding the column binding information by index.
This variable holds an array of all the columns.
This array is used whenever you get a column using an index.
Definition at line 333 of file record.h.
Referenced by bind_impl(), empty(), find_column(), and size().
odbcpp::dynamic_record::f_bind_by_name [private] |
Map holding the column binding information by name.
This variable holds all the named columns ordered by name.
It is used internally to quickly find the columns by name (i.e. whenever you use one of the get() functions with a column name instead of an index.)
Definition at line 332 of file record.h.
Referenced by bind_impl(), empty(), exists(), and find_column().