From f8d8de4ef1ec010cb81c75b00d8229204e7b1788 Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Tue, 15 Nov 2011 11:36:05 +0200 Subject: Use Oracle NUMBER to store returning ID value in 32-bit insert statement impl --- odb/oracle/statement.cxx | 18 +++++++++++------- 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 (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 #include +#include #include 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; }; -- cgit v1.1