This class represents query result. More...
#include <cppdb/backend.h>
Public Types | |
enum | next_row { last_row_reached, next_row_exists, next_row_unknown } |
Public Member Functions | |
virtual next_row | has_next ()=0 |
virtual bool | next ()=0 |
virtual bool | fetch (int col, short &v)=0 |
virtual bool | fetch (int col, unsigned short &v)=0 |
virtual bool | fetch (int col, int &v)=0 |
virtual bool | fetch (int col, unsigned &v)=0 |
virtual bool | fetch (int col, long &v)=0 |
virtual bool | fetch (int col, unsigned long &v)=0 |
virtual bool | fetch (int col, long long &v)=0 |
virtual bool | fetch (int col, unsigned long long &v)=0 |
virtual bool | fetch (int col, float &v)=0 |
virtual bool | fetch (int col, double &v)=0 |
virtual bool | fetch (int col, long double &v)=0 |
virtual bool | fetch (int col, std::string &v)=0 |
virtual bool | fetch (int col, std::ostream &v)=0 |
virtual bool | fetch (int col, std::tm &v)=0 |
virtual bool | is_null (int col)=0 |
virtual int | cols ()=0 |
virtual int | name_to_column (std::string const &)=0 |
virtual std::string | column_to_name (int)=0 |
This class represents query result.
This object is created by statement::query call, backend developer may assume that this object will stay alive as long as statement that created it exits, i.e. statement would be destroyed after result.
virtual int cppdb::backend::result::cols | ( | ) | [pure virtual] |
Return the number of columns in the result. Should be valid even without calling next() first time.
virtual std::string cppdb::backend::result::column_to_name | ( | int | ) | [pure virtual] |
Return the column name for column index starting from 0. Should throw invalid_column() if the index out of range Should be able to work even without calling next() first time.
virtual bool cppdb::backend::result::fetch | ( | int | col, |
short & | v | ||
) | [pure virtual] |
Fetch an integer value for column col starting from 0.
Should throw invalid_column() col value is invalid, should throw bad_value_cast() if the underlying data can't be converted to integer or its range is not supported by the integer type.
virtual bool cppdb::backend::result::fetch | ( | int | col, |
unsigned short & | v | ||
) | [pure virtual] |
Fetch an integer value for column col starting from 0. Returns true if ok, returns false if the column value is NULL and the referenced object should remain unchanged
Should throw invalid_column() col value is invalid, should throw bad_value_cast() if the underlying data can't be converted to integer or its range is not supported by the integer type.
virtual bool cppdb::backend::result::fetch | ( | int | col, |
int & | v | ||
) | [pure virtual] |
Fetch an integer value for column col starting from 0. Returns true if ok, returns false if the column value is NULL and the referenced object should remain unchanged
Should throw invalid_column() col value is invalid, should throw bad_value_cast() if the underlying data can't be converted to integer or its range is not supported by the integer type.
virtual bool cppdb::backend::result::fetch | ( | int | col, |
unsigned & | v | ||
) | [pure virtual] |
Fetch an integer value for column col starting from 0. Returns true if ok, returns false if the column value is NULL and the referenced object should remain unchanged
Should throw invalid_column() col value is invalid, should throw bad_value_cast() if the underlying data can't be converted to integer or its range is not supported by the integer type.
virtual bool cppdb::backend::result::fetch | ( | int | col, |
long & | v | ||
) | [pure virtual] |
Fetch an integer value for column col starting from 0. Returns true if ok, returns false if the column value is NULL and the referenced object should remain unchanged
Should throw invalid_column() col value is invalid, should throw bad_value_cast() if the underlying data can't be converted to integer or its range is not supported by the integer type.
virtual bool cppdb::backend::result::fetch | ( | int | col, |
unsigned long & | v | ||
) | [pure virtual] |
Fetch an integer value for column col starting from 0. Returns true if ok, returns false if the column value is NULL and the referenced object should remain unchanged
Should throw invalid_column() col value is invalid, should throw bad_value_cast() if the underlying data can't be converted to integer or its range is not supported by the integer type.
virtual bool cppdb::backend::result::fetch | ( | int | col, |
long long & | v | ||
) | [pure virtual] |
Fetch an integer value for column col starting from 0. Returns true if ok, returns false if the column value is NULL and the referenced object should remain unchanged
Should throw invalid_column() col value is invalid, should throw bad_value_cast() if the underlying data can't be converted to integer or its range is not supported by the integer type.
virtual bool cppdb::backend::result::fetch | ( | int | col, |
unsigned long long & | v | ||
) | [pure virtual] |
Fetch an integer value for column col starting from 0. Returns true if ok, returns false if the column value is NULL and the referenced object should remain unchanged
Should throw invalid_column() col value is invalid, should throw bad_value_cast() if the underlying data can't be converted to integer or its range is not supported by the integer type.
virtual bool cppdb::backend::result::fetch | ( | int | col, |
float & | v | ||
) | [pure virtual] |
Fetch a floating point value for column col starting from 0. Returns true if ok, returns false if the column value is NULL and the referenced object should remain unchanged
Should throw invalid_column() col value is invalid, should throw bad_value_cast() if the underlying data can't be converted to floating point value.
virtual bool cppdb::backend::result::fetch | ( | int | col, |
double & | v | ||
) | [pure virtual] |
Fetch a floating point value for column col starting from 0. Returns true if ok, returns false if the column value is NULL and the referenced object should remain unchanged
Should throw invalid_column() col value is invalid, should throw bad_value_cast() if the underlying data can't be converted to floating point value.
virtual bool cppdb::backend::result::fetch | ( | int | col, |
long double & | v | ||
) | [pure virtual] |
Fetch a floating point value for column col starting from 0. Returns true if ok, returns false if the column value is NULL and the referenced object should remain unchanged
Should throw invalid_column() col value is invalid, should throw bad_value_cast() if the underlying data can't be converted to floating point value.
virtual bool cppdb::backend::result::fetch | ( | int | col, |
std::string & | v | ||
) | [pure virtual] |
Fetch a string value for column col starting from 0. Returns true if ok, returns false if the column value is NULL and the referenced object should remain unchanged
Should throw invalid_column() col value is invalid, any data should be convertible to text value (as formatting integer, floating point value or date-time as string).
virtual bool cppdb::backend::result::fetch | ( | int | col, |
std::ostream & | v | ||
) | [pure virtual] |
Fetch a BLOB value for column col starting from 0. Returns true if ok, returns false if the column value is NULL and the referenced object should remain unchanged
Should throw invalid_column() col value is invalid, any data should be convertible to BLOB value as text (as formatting integer, floating point value or date-time as string).
virtual bool cppdb::backend::result::fetch | ( | int | col, |
std::tm & | v | ||
) | [pure virtual] |
Fetch a date-time value for column col starting from 0. Returns true if ok, returns false if the column value is NULL and the referenced object should remain unchanged
Should throw invalid_column() col value is invalid. If the data can't be converted to date-time it should throw bad_value_cast()
virtual next_row cppdb::backend::result::has_next | ( | ) | [pure virtual] |
Check if the next row in the result exists. If the DB engine can't perform this check without loosing data for current row, it should return next_row_unknown.
virtual bool cppdb::backend::result::is_null | ( | int | col | ) | [pure virtual] |
Check if the column col is NULL starting from 0, should throw invalid_column() if the index out of range
virtual int cppdb::backend::result::name_to_column | ( | std::string const & | ) | [pure virtual] |
Return the number of columns by its name. Return -1 if the name is invalid Should be able to work even without calling next() first time.
virtual bool cppdb::backend::result::next | ( | ) | [pure virtual] |
Move to next row. Should be called before first access to any of members. If no rows remain return false, otherwise return true