aboutsummaryrefslogtreecommitdiff
path: root/odb/oracle/query.txx
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-10-25 07:20:24 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-10-26 15:43:00 +0200
commit4a23d7554de82ba24d10bfc6d165157d113fa447 (patch)
treea96e57cc92745466fee5a9678d8e6c9e33652580 /odb/oracle/query.txx
parent9ce6c9851b48e575f712b6c30520211315811253 (diff)
Add query and result implementations
Diffstat (limited to 'odb/oracle/query.txx')
-rw-r--r--odb/oracle/query.txx111
1 files changed, 111 insertions, 0 deletions
diff --git a/odb/oracle/query.txx b/odb/oracle/query.txx
new file mode 100644
index 0000000..b8bd3c5
--- /dev/null
+++ b/odb/oracle/query.txx
@@ -0,0 +1,111 @@
+// file : odb/oracle/query.txx
+// author : Constantin Michael <constantin@codesynthesis.com>
+// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+// license : ODB NCUEL; see accompanying LICENSE file
+
+namespace odb
+{
+ namespace oracle
+ {
+ // query
+ //
+
+ template <database_type_id ID>
+ query::
+ query (const query_column<bool, ID>& c)
+ : binding_ (0, 0)
+ {
+ // Cannot use IS TRUE here since database type can be a non-
+ // integral type.
+ //
+ append (c.table (), c.column ());
+ append ("=");
+ append<bool, ID> (val_bind<bool> (true));
+ }
+
+ // query_column
+ //
+ template <typename T, database_type_id ID>
+ query query_column<T, ID>::
+ in (const T& v1, const T& v2) const
+ {
+ query q (table_, column_);
+ q += "IN (";
+ q.append<T, ID> (val_bind<T> (v1));
+ q += ",";
+ q.append<T, ID> (val_bind<T> (v2));
+ q += ")";
+ return q;
+ }
+
+ template <typename T, database_type_id ID>
+ query query_column<T, ID>::
+ in (const T& v1, const T& v2, const T& v3) const
+ {
+ query q (table_, column_);
+ q += "IN (";
+ q.append<T, ID> (val_bind<T> (v1));
+ q += ",";
+ q.append<T, ID> (val_bind<T> (v2));
+ q += ",";
+ q.append<T, ID> (val_bind<T> (v3));
+ q += ")";
+ return q;
+ }
+
+ template <typename T, database_type_id ID>
+ query query_column<T, ID>::
+ in (const T& v1, const T& v2, const T& v3, const T& v4) const
+ {
+ query q (table_, column_);
+ q += "IN (";
+ q.append<T, ID> (val_bind<T> (v1));
+ q += ",";
+ q.append<T, ID> (val_bind<T> (v2));
+ q += ",";
+ q.append<T, ID> (val_bind<T> (v3));
+ q += ",";
+ q.append<T, ID> (val_bind<T> (v4));
+ q += ")";
+ return q;
+ }
+
+ template <typename T, database_type_id ID>
+ query query_column<T, ID>::
+ in (const T& v1, const T& v2, const T& v3, const T& v4, const T& v5) const
+ {
+ query q (table_, column_);
+ q += "IN (";
+ q.append<T, ID> (val_bind<T> (v1));
+ q += ",";
+ q.append<T, ID> (val_bind<T> (v2));
+ q += ",";
+ q.append<T, ID> (val_bind<T> (v3));
+ q += ",";
+ q.append<T, ID> (val_bind<T> (v4));
+ q += ",";
+ q.append<T, ID> (val_bind<T> (v5));
+ q += ")";
+ return q;
+ }
+
+ template <typename T, database_type_id ID>
+ template <typename I>
+ query query_column<T, ID>::
+ in_range (I begin, I end) const
+ {
+ query q (table_, column_);
+ q += "IN (";
+
+ for (I i (begin); i != end; ++i)
+ {
+ if (i != begin)
+ q += ",";
+
+ q.append<T, ID> (val_bind<T> (*i));
+ }
+ q += ")";
+ return q;
+ }
+ }
+}