aboutsummaryrefslogtreecommitdiff
path: root/prepared/driver.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'prepared/driver.cxx')
-rw-r--r--prepared/driver.cxx9
1 files changed, 4 insertions, 5 deletions
diff --git a/prepared/driver.cxx b/prepared/driver.cxx
index 7d561a9..d805ddb 100644
--- a/prepared/driver.cxx
+++ b/prepared/driver.cxx
@@ -206,7 +206,6 @@ main (int argc, char* argv[])
{
typedef odb::query<person_count> query;
typedef odb::prepared_query<person_count> prep_query;
- typedef odb::result<person_count> result;
transaction t (db->begin ());
@@ -215,11 +214,11 @@ main (int argc, char* argv[])
prep_query pq (
db->prepare_query<person_count> ("person-count-age-query", q));
+ // Because an aggregate query result always contains one element,
+ // we use execute_value() insetad of execute() as a shortcut:
+ //
for (age = 90; age > 40; age -= 10)
- {
- result r (pq.execute ());
- cout << "over " << age << ": " << r.begin ()->count << endl;
- }
+ cout << "over " << age << ": " << pq.execute_value ().count << endl;
t.commit ();
}