diff options
author | Constantin Michael <constantin@codesynthesis.com> | 2011-11-15 11:36:05 +0200 |
---|---|---|
committer | Constantin Michael <constantin@codesynthesis.com> | 2011-11-16 12:48:18 +0200 |
commit | f8d8de4ef1ec010cb81c75b00d8229204e7b1788 (patch) | |
tree | 7137a795683758710d60b18c9d24b4b59d95db29 | |
parent | 7f348b4e2874d7aa39fbf093e56323f6e73ca052 (diff) |
Use Oracle NUMBER to store returning ID value in 32-bit insert statement impl
-rw-r--r-- | odb/oracle/statement.cxx | 18 | ||||
-rw-r--r-- | odb/oracle/statement.hxx | 15 |
2 files changed, 22 insertions, 11 deletions
diff --git a/odb/oracle/statement.cxx b/odb/oracle/statement.cxx index c6fa745..d056a76 100644 --- a/odb/oracle/statement.cxx +++ b/odb/oracle/statement.cxx @@ -1419,11 +1419,12 @@ namespace odb #if (OCI_MAJOR_VERSION == 11 && OCI_MINOR_VERSION >=2) \ || OCI_MAJOR_VERSION > 11 - *buffer = &b.id.value64; + *buffer = &b.id.integer; **size = sizeof (unsigned long long); #else - *buffer = &b.id.value32; - **size = sizeof (unsigned int); + *buffer = b.id.number.buffer; + *size = &b.id.number.size; + b.id.number.size = 21; #endif *indicator = &b.indicator; @@ -1475,10 +1476,11 @@ namespace odb #if (OCI_MAJOR_VERSION == 11 && OCI_MINOR_VERSION >=2) \ || OCI_MAJOR_VERSION > 11 sizeof (unsigned long long), + SQLT_UIN, #else - sizeof (unsigned int), + 21, + SQLT_NUM, #endif - SQLT_UIN, 0, 0, 0, @@ -1560,9 +1562,11 @@ namespace odb { #if (OCI_MAJOR_VERSION == 11 && OCI_MINOR_VERSION >=2) \ || OCI_MAJOR_VERSION > 11 - return id_bind_.id.value64; + return id_bind_.id.integer; #else - return id_bind_.id.value32; + return details::number_to_uint64 ( + id_bind_.id.number.buffer, + static_cast <std::size_t> (id_bind_.id.number.size)); #endif } diff --git a/odb/oracle/statement.hxx b/odb/oracle/statement.hxx index 3687728..2e5c6ba 100644 --- a/odb/oracle/statement.hxx +++ b/odb/oracle/statement.hxx @@ -20,6 +20,7 @@ #include <odb/oracle/oracle-fwd.hxx> #include <odb/oracle/auto-handle.hxx> +#include <odb/oracle/details/number.hxx> #include <odb/oracle/details/export.hxx> namespace odb @@ -213,16 +214,22 @@ namespace odb // Only OCI versions 11.2 and greater support conversion of the internal // Oracle type NUMBER to an external 64-bit integer type. If we detect // version 11.2 or greater we provide an unsigned long long image. - // Otherwise, we revert to using a 32-bit unsigned integer. + // Otherwise, we revert to using a NUMBER image and manipulate it using + // the custom conversion algorithms found in details/number.hxx. // public: struct id_bind_type { union { - unsigned int value32; - unsigned long long value64; - } id; + struct + { + char buffer[21]; + ub4 size; + } number; + + unsigned long long integer; + }id; sb2 indicator; }; |