1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
14 #include <anna/config/defines.hpp>
15 #include <anna/core/tracing/Logger.hpp>
17 #include <anna/dbms.oracle/ResultCode.hpp>
20 using namespace anna::dbms;
22 oracle::ResultCode::ErrorDecoder oracle::ResultCode::st_errorDecoder;
24 oracle::ResultCode::ResultCode(const int status, OCIError* error) :
25 dbms::ResultCode(0, NULL, &st_errorDecoder) {
26 char errorText [dbms::ResultCode::MaxErrorLen];
27 int errorCode = status;
29 if(status == OCI_SUCCESS) {
30 dbms::ResultCode::set(OCI_SUCCESS, NULL);
32 } else if(status == OCI_SUCCESS_WITH_INFO) {
33 OCIErrorGet(error, (ub4) 1, (text*) 0, &errorCode, (unsigned char*) errorText, (ub4) sizeof(errorText), OCI_HTYPE_ERROR);
34 dbms::ResultCode::set(OCI_SUCCESS, errorText);
35 LOGINFORMATION(Logger::information(asString(), ANNA_FILE_LOCATION));
41 OCIErrorGet(error, (ub4) 1, (text*) 0, &errorCode, (unsigned char*) errorText, (ub4) sizeof(errorText), OCI_HTYPE_ERROR);
43 case OCI_NEED_DATA: anna_strcpy(errorText, "OCI | Need data"); break;
44 case OCI_NO_DATA: anna_strcpy(errorText, "OCI | Data not found"); break;
45 case OCI_INVALID_HANDLE: anna_strcpy(errorText, "OCI | Invalid handle"); break;
46 default: sprintf(errorText, "OCI | Error code: %d", status); break;
49 dbms::ResultCode::set(errorCode, errorText);
52 bool oracle::ResultCode::ErrorDecoder::notFound(const int errorCode) const
54 return errorCode == OCI_NO_DATA;
57 bool oracle::ResultCode::ErrorDecoder::successful(const int errorCode) const
59 return errorCode == OCI_SUCCESS;
62 bool oracle::ResultCode::ErrorDecoder::lostConnection(const int errorCode) const
64 return errorCode == 28 || errorCode == 3113 || errorCode == 3114 || errorCode == 1012 || errorCode == 12570 || errorCode == 12571;