diff options
author | Constantin Michael <constantin@codesynthesis.com> | 2011-11-30 10:45:39 +0200 |
---|---|---|
committer | Constantin Michael <constantin@codesynthesis.com> | 2011-11-30 11:32:08 +0200 |
commit | b7f64fe7f65eb286b5b0c93776fe38bd682b9552 (patch) | |
tree | 3f05495eb0eaff8c2760a962b1d1d81b2aec331a | |
parent | 4cf24ec9ce581cdb68f53a9066e0de504031f073 (diff) |
Provide separate overload of translate_error for oracle::connection
-rw-r--r-- | odb/oracle/error.cxx | 28 | ||||
-rw-r--r-- | odb/oracle/error.hxx | 23 | ||||
-rw-r--r-- | odb/oracle/statement.cxx | 22 | ||||
-rw-r--r-- | odb/oracle/transaction-impl.cxx | 6 |
4 files changed, 46 insertions, 33 deletions
diff --git a/odb/oracle/error.cxx b/odb/oracle/error.cxx index fe782f4..008591a 100644 --- a/odb/oracle/error.cxx +++ b/odb/oracle/error.cxx @@ -5,6 +5,8 @@ #include <cassert> +#include <oci.h> + #include <odb/details/buffer.hxx> #include <odb/oracle/error.hxx> @@ -17,7 +19,7 @@ namespace odb { namespace oracle { - void + static void translate_error (void* h, ub4 t, sword s, connection* conn) { assert (s != OCI_SUCCESS && s != OCI_SUCCESS_WITH_INFO); @@ -45,7 +47,7 @@ namespace odb } } - sword r (0); + sword r; sb4 e; char b[512]; // Error message will be truncated if it does not fit. @@ -55,7 +57,7 @@ namespace odb // if (conn != 0) { - OCIServer* server (0); + OCIServer* server; r = OCIAttrGet (conn->handle (), OCI_HTYPE_SVCCTX, &server, @@ -66,7 +68,7 @@ namespace odb if (r != OCI_SUCCESS) throw invalid_oci_handle (); - ub4 server_status (0); + ub4 server_status; r = OCIAttrGet (server, OCI_HTYPE_SERVER, &server_status, @@ -172,5 +174,23 @@ namespace odb throw dbe; } + + void + translate_error (OCIError* h, sword result) + { + translate_error (h, OCI_HTYPE_ERROR, result, 0); + } + + void + translate_error (connection& c, sword result) + { + translate_error (c.error_handle (), OCI_HTYPE_ERROR, result, &c); + } + + void + translate_error (OCIEnv* h) + { + translate_error (h, OCI_HTYPE_ENV, OCI_ERROR, 0); + } } } diff --git a/odb/oracle/error.hxx b/odb/oracle/error.hxx index a5dbb10..a715bce 100644 --- a/odb/oracle/error.hxx +++ b/odb/oracle/error.hxx @@ -8,8 +8,7 @@ #include <odb/pre.hxx> -#include <oci.h> - +#include <odb/oracle/oracle-fwd.hxx> #include <odb/oracle/forward.hxx> #include <odb/oracle/version.hxx> #include <odb/oracle/details/export.hxx> @@ -18,26 +17,20 @@ namespace odb { namespace oracle { - void - translate_error (void* h, ub4 t, sword s, connection*); - // Translate OCI error given an error handle and throw an appropriate // exception. // - inline LIBODB_ORACLE_EXPORT void - translate_error (OCIError* h, sword s, connection* c = 0) - { - translate_error (h, OCI_HTYPE_ERROR, s, c); - } + LIBODB_ORACLE_EXPORT void + translate_error (OCIError* h, sword result); + + LIBODB_ORACLE_EXPORT void + translate_error (connection& c, sword result); // Translate an OCI error given an environment handle error and throw // an appropriate exception. // - inline LIBODB_ORACLE_EXPORT void - translate_error (OCIEnv* h) - { - translate_error (h, OCI_HTYPE_ENV, OCI_ERROR, 0); - } + LIBODB_ORACLE_EXPORT void + translate_error (OCIEnv* h); } } diff --git a/odb/oracle/statement.cxx b/odb/oracle/statement.cxx index 26f1358..47e2be5 100644 --- a/odb/oracle/statement.cxx +++ b/odb/oracle/statement.cxx @@ -229,7 +229,7 @@ namespace odb OCI_DEFAULT)); if (r == OCI_ERROR || r == OCI_INVALID_HANDLE) - translate_error (err, r, &conn_); + translate_error (conn_, r); stmt_.reset (handle, OCI_STRLS_CACHE_DELETE, err); @@ -1023,7 +1023,7 @@ namespace odb cs_form); if (r == OCI_ERROR || r == OCI_INVALID_HANDLE) - translate_error (err, r, &conn_); + translate_error (conn_, r); chunk_position cp; @@ -1114,7 +1114,7 @@ namespace odb r = OCIStmtExecute (handle, stmt_, err, 0, 0, 0, 0, OCI_DEFAULT); if (r == OCI_ERROR || r == OCI_INVALID_HANDLE) - translate_error (err, r, &conn_); + translate_error (conn_, r); // In order to successfully execute a select statement, OCI/Oracle // requires that there be OCIDefine handles provided for all select @@ -1195,7 +1195,7 @@ namespace odb // and ignore this error. // if (e != 1406) - translate_error (err, r, &conn_); + translate_error (conn_, r); } else if (r == OCI_INVALID_HANDLE) translate_error (err, r); @@ -1208,7 +1208,7 @@ namespace odb r = OCIStmtExecute (handle, stmt_, err, 1, 0, 0, 0, OCI_DEFAULT); if (r == OCI_ERROR || r == OCI_INVALID_HANDLE) - translate_error (err, r, &conn_); + translate_error (conn_, r); } ub4 row_count (0); @@ -1328,7 +1328,7 @@ namespace odb OCI_DEFAULT)); if (r == OCI_ERROR || r == OCI_INVALID_HANDLE) - translate_error (err, r, &conn_); + translate_error (conn_, r); done_ = r == OCI_NO_DATA; @@ -1372,7 +1372,7 @@ namespace odb OCI_DEFAULT)); if (r == OCI_ERROR || r == OCI_INVALID_HANDLE) - translate_error (conn_.error_handle (), r, &conn_); + translate_error (conn_, r); else if (r == OCI_NO_DATA) done_ = true; } @@ -1393,7 +1393,7 @@ namespace odb OCI_DEFAULT)); if (r == OCI_ERROR || r == OCI_INVALID_HANDLE) - translate_error (conn_.error_handle (), r, &conn_); + translate_error (conn_, r); done_ = true; } @@ -1561,7 +1561,7 @@ namespace odb if (e == 1) return false; else - translate_error (err, r, &conn_); + translate_error (conn_, r); } ub4 row_count (0); @@ -1640,7 +1640,7 @@ namespace odb OCI_DEFAULT)); if (r == OCI_ERROR || r == OCI_INVALID_HANDLE) - translate_error (err, r, &conn_); + translate_error (conn_, r); ub4 row_count (0); r = OCIAttrGet (stmt_, @@ -1706,7 +1706,7 @@ namespace odb OCI_DEFAULT)); if (r == OCI_ERROR || r == OCI_INVALID_HANDLE) - translate_error (err, r, &conn_); + translate_error (conn_, r); ub4 row_count (0); r = OCIAttrGet (stmt_, diff --git a/odb/oracle/transaction-impl.cxx b/odb/oracle/transaction-impl.cxx index a22d5c7..865b9d2 100644 --- a/odb/oracle/transaction-impl.cxx +++ b/odb/oracle/transaction-impl.cxx @@ -106,7 +106,7 @@ namespace odb OCI_TRANS_NEW); if (s == OCI_ERROR || s == OCI_INVALID_HANDLE) - translate_error (err, s, connection_.get ()); + translate_error (*connection_, s); } void transaction_impl:: @@ -123,7 +123,7 @@ namespace odb OCI_DEFAULT)); if (s == OCI_ERROR || s == OCI_INVALID_HANDLE) - translate_error (connection_->error_handle (), s, connection_.get ()); + translate_error (*connection_, s); } void transaction_impl:: @@ -140,7 +140,7 @@ namespace odb OCI_DEFAULT)); if (s == OCI_ERROR || s == OCI_INVALID_HANDLE) - translate_error (connection_->error_handle (), s, connection_.get ()); + translate_error (*connection_, s); } } } |