A class template of which each instantiation class represents the rows of a relational table. More...
#include <row.h>
Classes | |
struct | Column |
A Row<T>::Column object should be considered as a reference to a Table::Column object. More... | |
class | Set |
A set of rows of this table. More... | |
Public Member Functions | |
Row () | |
An empty row. | |
Row (SelectExp select_exp, const std::string &rest="") throw (std::logic_error, std::runtime_error) | |
Initialize a row object with data matching the first result in an SQL select statement defined by select_exp followed by rest. | |
Row (Dv::Sql::Command &q, unsigned int r) throw (std::logic_error, std::runtime_error) | |
Initialize a row object with data from the r'th row in the answer of a query q. | |
Row (const Dv::Sql::Object &source, const Dv::Sql::Reference &reference) throw (std::runtime_error, std::logic_error) | |
Initialize a row using data from a row that is obtained by "following a reference". | |
bool | is_null (const Column &column) const |
Is the column value null? | |
template<typename T > | |
T | operator() (const Column &column, const T &default_value) const |
Obtain column value for a row. | |
Static Public Member Functions | |
static Dv::Sql::Table::Ref | table () |
static Dv::Sql::Db & | db () |
static void | erase_all (SelectExp select_exp) |
A class template of which each instantiation class represents the rows of a relational table.
The template parameter is a (reference to) a Dv::Sql::Table object, for which the class instances represent rows. A Row object is essentially a Dv::Sql::Object with a fixed associated database table (note that the association between an object and a database table cannot be changed: see Dv::Sql::Object::set_table).
Definition at line 25 of file row.h.
Dv::Sql::Row< database_table >::Row | ( | ) | [inline] |
An empty row.
Dv::Sql::Row< database_table >::Row | ( | SelectExp | select_exp, | |
const std::string & | rest = "" | |||
) | throw (std::logic_error, std::runtime_error) [inline] |
Initialize a row object with data matching the first result in an SQL select statement defined by select_exp followed by rest.
std::string n("Jones"0; Row<customer> customer(name == n, "order by age");
select_exp | boolean condition that is translated to the "where" clause in the SQL select statement. | |
rest | optional part of the SQL select statement follwing the "where" clause. |
std::runtime_error | if the query returns no anwers | |
std::logic_error | if the query caused an SQL error |
Dv::Sql::Row< database_table >::Row | ( | Dv::Sql::Command & | q, | |
unsigned int | r | |||
) | throw (std::logic_error, std::runtime_error) [inline] |
Initialize a row object with data from the r'th row in the answer of a query q.
Db::Sql::Command q(db, "select * from customer where", age < 21 && name ^ "A%", "order by age"); Row<customer> customer(q, 2);
q | the query for which the answer will supply the data to initialize the row object | |
r | the number of the row in the query answer from which the data will be used to initialize this row object. |
std::runtime_error | if the query returns less than r answers | |
std::logic_error | if the query caused an SQL error or if the number of columns in the query answer is not equal to the number of columns in table_ref (the template parameter). |
Dv::Sql::Row< database_table >::Row | ( | const Dv::Sql::Object & | source, | |
const Dv::Sql::Reference & | reference | |||
) | throw (std::runtime_error, std::logic_error) [inline] |
Initialize a row using data from a row that is obtained by "following a reference".
The data are obtained from the first row of the result of a query that selects the rows of the target table that match data from the source object in the colums indicated by the reference object.
// Define reference from account(customer_id) to customer(id) const Dv::Sql::Reference acct_cust( Database::account, (cols = &Account::customer_id), Database::customer, (cols = &Customer::id) ); Row<account> acct; // Cust will be initialized using data from the first // (only) customer with id acct.cust_id Row<customer> cust(acct, acct_cust);
source | object from which the reference will be followed. It should be a row from reference.from_table. | |
reference | that will be followed. Its to_table should match database_table (the template parameter) of this object. |
std::runtime_error | if the resulting query returns no answers | |
std::logic_error | if the query caused an SQL error or if the number of columns in the query answer is not equal to the number of columns in table_ref (the template parameter) or if the number of columns in the source object does not equal the number of columns in reference.from_table. |
static Dv::Sql::Table::Ref Dv::Sql::Row< database_table >::table | ( | ) | [inline, static] |
Definition at line 28 of file row.h.
Referenced by Dv::Sql::Row< database_table >::erase_all().
static Dv::Sql::Db& Dv::Sql::Row< database_table >::db | ( | ) | [inline, static] |
Definition at line 29 of file row.h.
Referenced by Dv::Sql::Row< database_table >::erase_all().
static void Dv::Sql::Row< database_table >::erase_all | ( | SelectExp | select_exp | ) | [inline, static] |
Definition at line 117 of file row.h.
References Dv::Sql::Row< database_table >::db(), and Dv::Sql::Row< database_table >::table().
bool Dv::Sql::Row< database_table >::is_null | ( | const Column & | column | ) | const [inline] |
Is the column value null?
column | as generated by db2cpp |
Definition at line 166 of file row.h.
References Dv::Sql::Column::index().
T Dv::Sql::Row< database_table >::operator() | ( | const Column & | column, | |
const T & | default_value | |||
) | const [inline] |
Obtain column value for a row.
column | as generated by db2cpp | |
default_value | returned if the 'real' value of the column is null, should enable automatic deduction of T |
Definition at line 177 of file row.h.
References Dv::Sql::Column::index().
dvmysql-1.0.3 | [17 November, 2010] |