From a45971aa9ea5b563be0da82b25b374465af513b0 Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Fri, 18 Nov 2011 11:13:10 +0200 Subject: Explicitly set the OCI_ATTR_MAXDATA_SIZE attribute to avoid ORA-24816 error --- odb/oracle/statement.cxx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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, ¶m_callback_proxy, 0, 0); -- cgit v1.1