aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-11-18 11:13:10 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-11-18 11:54:42 +0200
commita45971aa9ea5b563be0da82b25b374465af513b0 (patch)
treedb3200a929688504c238c249d15d4bbebb9f9e41
parente755248d95e857d93c24301fbacde974ae6ffb03 (diff)
Explicitly set the OCI_ATTR_MAXDATA_SIZE attribute to avoid ORA-24816 error
-rw-r--r--odb/oracle/statement.cxx21
1 files changed, 20 insertions, 1 deletions
diff --git a/odb/oracle/statement.cxx b/odb/oracle/statement.cxx
index 9a5c0e6..6ca3af7 100644
--- a/odb/oracle/statement.cxx
+++ b/odb/oracle/statement.cxx
@@ -577,7 +577,6 @@ namespace odb
if (b->type == bind::nstring || b->type == bind::nclob)
{
ub1 form (SQLCS_NCHAR);
-
r = OCIAttrSet (h,
OCI_HTYPE_BIND,
&form,
@@ -589,6 +588,26 @@ namespace odb
translate_error (err, r);
}
+ if (b->type == bind::string || b->type == bind::nstring)
+ {
+ // Set the maximum data size for all string types. If this is not set
+ // Oracle server will implicitly calculate this maximum size. If the
+ // calculated size exceeds 4000 bytes (which may occur if a character
+ // set conversion is required) and the string is bound after a LOB
+ // binding, the server will return an ORA-24816 error.
+ //
+ sb4 n (4000);
+ r = OCIAttrSet (h,
+ OCI_HTYPE_BIND,
+ &n,
+ 9,
+ OCI_ATTR_MAXDATA_SIZE,
+ err);
+
+ if (r == OCI_ERROR || r == OCI_INVALID_HANDLE)
+ translate_error (err, r);
+ }
+
if (callback)
{
r = OCIBindDynamic (h, err, b, &param_callback_proxy, 0, 0);