aboutsummaryrefslogtreecommitdiff
path: root/odb/oracle/oracle-types.cxx
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-11-07 15:02:14 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-11-08 14:46:33 +0200
commit655fc5c0827d56b6eaa86f80c904d9a607530fcb (patch)
treecf4679282bb15dd15c73ff429e0b20428eb58650 /odb/oracle/oracle-types.cxx
parent60d4d13a85130ccdc3b232e420bc3c18683846b9 (diff)
Implement support for Oracle temporal types
Diffstat (limited to 'odb/oracle/oracle-types.cxx')
-rw-r--r--odb/oracle/oracle-types.cxx135
1 files changed, 135 insertions, 0 deletions
diff --git a/odb/oracle/oracle-types.cxx b/odb/oracle/oracle-types.cxx
new file mode 100644
index 0000000..17ae479
--- /dev/null
+++ b/odb/oracle/oracle-types.cxx
@@ -0,0 +1,135 @@
+// file : odb/oracle/oracle-types.hxx
+// author : Constantin Michael <constantin@codesynthesis.com>
+// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC
+// license : ODB NCUEL; see accompanying LICENSE file
+
+#include <cassert>
+
+#include <oci.h>
+
+#include <odb/oracle/oracle-types.hxx>
+#include <odb/oracle/error.hxx>
+
+namespace odb
+{
+ namespace oracle
+ {
+ void datetime::
+ get () const
+ {
+ assert (descriptor.get () != 0);
+
+ sword r (OCIDateTimeGetDate (descriptor.environment,
+ descriptor.error,
+ descriptor,
+ &fields.year,
+ &fields.month,
+ &fields.day));
+
+ if (r != OCI_SUCCESS)
+ translate_error (descriptor.error, r);
+
+ r = OCIDateTimeGetTime (descriptor.environment,
+ descriptor.error,
+ descriptor,
+ &fields.hour,
+ &fields.minute,
+ &fields.second,
+ &fields.nanosecond);
+
+ if (r != OCI_SUCCESS)
+ translate_error (descriptor.error, r);
+ }
+
+ void datetime::
+ set ()
+ {
+ if (descriptor.get () != 0)
+ {
+ sword r (OCIDateTimeConstruct (descriptor.environment,
+ descriptor.error,
+ descriptor,
+ fields.year,
+ fields.month,
+ fields.day,
+ fields.hour,
+ fields.minute,
+ fields.second,
+ fields.nanosecond,
+ 0,
+ 0));
+
+ if (r != OCI_SUCCESS)
+ translate_error (descriptor.error, r);
+ }
+ }
+
+ void interval_ym::
+ get () const
+ {
+ assert (descriptor.get () != 0);
+
+ sword r (OCIIntervalGetYearMonth (descriptor.environment,
+ descriptor.error,
+ &fields.year,
+ &fields.month,
+ descriptor));
+
+ if (r != OCI_SUCCESS)
+ translate_error (descriptor.error, r);
+ }
+
+ void interval_ym::
+ set ()
+ {
+ if (descriptor.get () != 0)
+ {
+ sword r (OCIIntervalSetYearMonth (descriptor.environment,
+ descriptor.error,
+ fields.year,
+ fields.month,
+ descriptor));
+
+ if (r != OCI_SUCCESS)
+ translate_error (descriptor.error, r);
+ }
+ }
+
+ void interval_ds::
+ get () const
+ {
+ assert (descriptor.get () != 0);
+
+ sword r (OCIIntervalGetDaySecond (descriptor.environment,
+ descriptor.error,
+ &fields.day,
+ &fields.hour,
+ &fields.minute,
+ &fields.second,
+ &fields.nanosecond,
+ descriptor));
+
+ if (r != OCI_SUCCESS)
+ translate_error (descriptor.error, r);
+ }
+
+ void interval_ds::
+ set ()
+ {
+ if (descriptor.get () != 0)
+ {
+ sword r (OCIIntervalSetDaySecond (descriptor.environment,
+ descriptor.error,
+ fields.day,
+ fields.hour,
+ fields.minute,
+ fields.second,
+ fields.nanosecond,
+ descriptor));
+
+ if (r != OCI_SUCCESS)
+ translate_error (descriptor.error, r);
+ }
+ }
+ }
+}