diff options
Diffstat (limited to 'odb/oracle/statement.cxx')
-rw-r--r-- | odb/oracle/statement.cxx | 115 |
1 files changed, 85 insertions, 30 deletions
diff --git a/odb/oracle/statement.cxx b/odb/oracle/statement.cxx index 27fa867..f4d9eef 100644 --- a/odb/oracle/statement.cxx +++ b/odb/oracle/statement.cxx @@ -1284,7 +1284,7 @@ namespace odb // Clear the status array. // - memset (status_, sizeof (status_), 0); + memset (status_, 0, n * sizeof (status_[0])); // @@ TODO allocate per batch stmt (maybe lazily here if NULL). // @@ -1314,7 +1314,7 @@ namespace odb if (r == OCI_ERROR || r == OCI_INVALID_HANDLE) translate_error (err1, r); - cerr << "NUM_DML_ERRORS: " << errors << endl; + //cerr << "NUM_DML_ERRORS: " << errors << endl; errors_ = errors; if (errors != 0) @@ -1393,7 +1393,7 @@ namespace odb rows = static_cast<unsigned long long> (n); } - cerr << "total: " << rows << endl; + //cerr << "total: " << rows << endl; if (n_ > 1) // Batch. { @@ -1869,12 +1869,11 @@ namespace odb // the last extracted size after OCIStmtExecute() below. Thanks, // Oracle! // - if (it != 0) - { - *reinterpret_cast<ub2*> ( - reinterpret_cast<char*> (b.size) + (it - 1) * skip) = - static_cast<ub2> (st.ret_size_); - } + if (st.ret_prev_ != 0) + *st.ret_prev_ = static_cast<ub2> (st.ret_size_); + + st.ret_prev_ = reinterpret_cast<ub2*> ( + reinterpret_cast<char*> (b.size) + it * skip); *size = &st.ret_size_; } @@ -1983,6 +1982,9 @@ namespace odb { OCIError* err (conn_.error_handle ()); + if (ret_ != 0) + ret_prev_ = 0; + // Ignore ORA-00001 error code, see fetch() below for details. // sword r (bulk_statement::execute (n, mex, (ret_ == 0 ? 1 : 0))); @@ -1995,34 +1997,25 @@ namespace odb sb4 e; OCIErrorGet (err, 1, 0, &e, 0, 0, OCI_HTYPE_ERROR); fetch (r, e); + + if (result_) // If fetch() hasn't translated the error. + translate_error (err, r, &conn_, 0, mex_); // Can return. + return n_; } // Store the last returned id size (see odb_oracle_returning_out() // for details). // - if (ret_ != 0) - { - size_t n (n_); - - // Find the index of the last sucessefully processed parameter set. - // - if (n != 1) - for (; n != 0 && status_[n - 1] != 0; --n) ; - - if (n != 0) // They all might have failed. - { - *reinterpret_cast<ub2*> ( - reinterpret_cast<char*> ( - ret_->bind[0].size) + (n - 1) * ret_->skip) = - static_cast<ub2> (ret_size_); - } - } + if (ret_ != 0 && ret_prev_ != 0) + *ret_prev_ = static_cast<ub2> (ret_size_); if (status_ == 0) // Non-batch mode. fetch (OCI_SUCCESS, 0); else + { fetch (status_[i_] == 0 ? OCI_SUCCESS : OCI_ERROR, status_[i_]); + } return n_; } @@ -2055,6 +2048,23 @@ namespace odb update_statement:: update_statement (connection_type& conn, const string& text, + bool process, + binding& param) + : bulk_statement (conn, + text, statement_update, + (process ? ¶m : 0), false, + param.batch, param.status), + unique_ (false) + { + assert (param.batch == 1); // Specify unique_hint explicitly. + + if (!empty ()) + bind_param (param.bind, param.count, param.batch, param.skip); + } + + update_statement:: + update_statement (connection_type& conn, + const string& text, bool unique, bool process, binding& param) @@ -2071,6 +2081,23 @@ namespace odb update_statement:: update_statement (connection_type& conn, const char* text, + bool process, + binding& param) + : bulk_statement (conn, + text, statement_update, + (process ? ¶m : 0), false, + param.batch, param.status), + unique_ (false) + { + assert (param.batch == 1); // Specify unique_hint explicitly. + + if (!empty ()) + bind_param (param.bind, param.count, param.batch, param.skip); + } + + update_statement:: + update_statement (connection_type& conn, + const char* text, bool unique, bool process, binding& param) @@ -2130,8 +2157,22 @@ namespace odb delete_statement:: delete_statement (connection_type& conn, const string& text, - binding& param, - bool unique) + binding& param) + : bulk_statement (conn, + text, statement_delete, + 0, false, + param.batch, param.status), + unique_ (false) + { + assert (param.batch == 1); // Specify unique_hint explicitly. + bind_param (param.bind, param.count, param.batch, param.skip); + } + + delete_statement:: + delete_statement (connection_type& conn, + const string& text, + bool unique, + binding& param) : bulk_statement (conn, text, statement_delete, 0, false, @@ -2144,8 +2185,22 @@ namespace odb delete_statement:: delete_statement (connection_type& conn, const char* text, - binding& param, - bool unique) + binding& param) + : bulk_statement (conn, + text, statement_delete, + 0, false, + param.batch, param.status), + unique_ (false) + { + assert (param.batch == 1); // Specify unique_hint explicitly. + bind_param (param.bind, param.count, param.batch, param.skip); + } + + delete_statement:: + delete_statement (connection_type& conn, + const char* text, + bool unique, + binding& param) : bulk_statement (conn, text, statement_delete, 0, false, |