From 62e234c114d2b6ead93a1d39593c66b648c3d0a6 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 1 Feb 2024 15:47:37 +0300 Subject: Turn libodb-oracle repository into package for muti-package repository --- libodb-oracle/odb/oracle/query.txx | 169 +++++++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 libodb-oracle/odb/oracle/query.txx (limited to 'libodb-oracle/odb/oracle/query.txx') diff --git a/libodb-oracle/odb/oracle/query.txx b/libodb-oracle/odb/oracle/query.txx new file mode 100644 index 0000000..65f2858 --- /dev/null +++ b/libodb-oracle/odb/oracle/query.txx @@ -0,0 +1,169 @@ +// file : odb/oracle/query.txx +// license : ODB NCUEL; see accompanying LICENSE file + +namespace odb +{ + namespace oracle + { + // + // query_base + // + + template + query_base:: + query_base (const query_column& 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 (val_bind (true, c.prec (), c.scale ()), + c.conversion ()); + } + + // + // query_column + // + + // in + // + template + query_base query_column:: + in (decayed_type v1, decayed_type v2) const + { + query_base q (table_, column_); + q += "IN ("; + q.append (val_bind (v1, prec_, scale_), conversion_); + q += ","; + q.append (val_bind (v2, prec_, scale_), conversion_); + q += ")"; + return q; + } + + template + query_base query_column:: + in (decayed_type v1, decayed_type v2, decayed_type v3) const + { + query_base q (table_, column_); + q += "IN ("; + q.append (val_bind (v1, prec_, scale_), conversion_); + q += ","; + q.append (val_bind (v2, prec_, scale_), conversion_); + q += ","; + q.append (val_bind (v3, prec_, scale_), conversion_); + q += ")"; + return q; + } + + template + query_base query_column:: + in (decayed_type v1, decayed_type v2, decayed_type v3, + decayed_type v4) const + { + query_base q (table_, column_); + q += "IN ("; + q.append (val_bind (v1, prec_, scale_), conversion_); + q += ","; + q.append (val_bind (v2, prec_, scale_), conversion_); + q += ","; + q.append (val_bind (v3, prec_, scale_), conversion_); + q += ","; + q.append (val_bind (v4, prec_, scale_), conversion_); + q += ")"; + return q; + } + + template + query_base query_column:: + in (decayed_type v1, decayed_type v2, decayed_type v3, decayed_type v4, + decayed_type v5) const + { + query_base q (table_, column_); + q += "IN ("; + q.append (val_bind (v1, prec_, scale_), conversion_); + q += ","; + q.append (val_bind (v2, prec_, scale_), conversion_); + q += ","; + q.append (val_bind (v3, prec_, scale_), conversion_); + q += ","; + q.append (val_bind (v4, prec_, scale_), conversion_); + q += ","; + q.append (val_bind (v5, prec_, scale_), conversion_); + q += ")"; + return q; + } + + template + template + query_base query_column:: + in_range (I begin, I end) const + { + if (begin != end) + { + query_base q (table_, column_); + q += "IN ("; + + for (I i (begin); i != end; ++i) + { + if (i != begin) + q += ","; + + q.append (val_bind (*i, prec_, scale_), conversion_); + } + + q += ")"; + return q; + } + else + return query_base (false); + } + + // like + // + template + query_base query_column:: + like (val_bind p) const + { + query_base q (table_, column_); + q += "LIKE"; + q.append (p, conversion_); + return q; + } + + template + query_base query_column:: + like (ref_bind p) const + { + query_base q (table_, column_); + q += "LIKE"; + q.append (p, conversion_); + return q; + } + + template + query_base query_column:: + like (val_bind p, decayed_type e) const + { + query_base q (table_, column_); + q += "LIKE"; + q.append (p, conversion_); + q += "ESCAPE"; + q.append (val_bind (e), conversion_); + return q; + } + + template + query_base query_column:: + like (ref_bind p, decayed_type e) const + { + query_base q (table_, column_); + q += "LIKE"; + q.append (p, conversion_); + q += "ESCAPE"; + q.append (val_bind (e), conversion_); + return q; + } + } +} -- cgit v1.1