+++ /dev/null
-// ANNA - Anna is Not Nothingness Anymore //
-// //
-// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
-// //
-// See project site at http://redmine.teslayout.com/projects/anna-suite //
-// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
-
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include <oci.h>
-
-#include <anna/config/defines.hpp>
-#include <anna/core/tracing/Logger.hpp>
-
-#include <anna/dbms.oracle/ResultCode.hpp>
-
-using namespace anna;
-using namespace anna::dbms;
-
-oracle::ResultCode::ErrorDecoder oracle::ResultCode::st_errorDecoder;
-
-oracle::ResultCode::ResultCode(const int status, OCIError* error) :
- dbms::ResultCode(0, NULL, &st_errorDecoder) {
- char errorText [dbms::ResultCode::MaxErrorLen];
- int errorCode = status;
-
- if(status == OCI_SUCCESS) {
- dbms::ResultCode::set(OCI_SUCCESS, NULL);
- return;
- } else if(status == OCI_SUCCESS_WITH_INFO) {
- OCIErrorGet(error, (ub4) 1, (text*) 0, &errorCode, (unsigned char*) errorText, (ub4) sizeof(errorText), OCI_HTYPE_ERROR);
- dbms::ResultCode::set(OCI_SUCCESS, errorText);
- LOGINFORMATION(Logger::information(asString(), ANNA_FILE_LOCATION));
- return;
- }
-
- switch(status) {
- case OCI_ERROR:
- OCIErrorGet(error, (ub4) 1, (text*) 0, &errorCode, (unsigned char*) errorText, (ub4) sizeof(errorText), OCI_HTYPE_ERROR);
- break;
- case OCI_NEED_DATA: anna_strcpy(errorText, "OCI | Need data"); break;
- case OCI_NO_DATA: anna_strcpy(errorText, "OCI | Data not found"); break;
- case OCI_INVALID_HANDLE: anna_strcpy(errorText, "OCI | Invalid handle"); break;
- default: sprintf(errorText, "OCI | Error code: %d", status); break;
- }
-
- dbms::ResultCode::set(errorCode, errorText);
-}
-
-bool oracle::ResultCode::ErrorDecoder::notFound(const int errorCode) const
-throw() {
- return errorCode == OCI_NO_DATA;
-}
-
-bool oracle::ResultCode::ErrorDecoder::successful(const int errorCode) const
-throw() {
- return errorCode == OCI_SUCCESS;
-}
-
-bool oracle::ResultCode::ErrorDecoder::lostConnection(const int errorCode) const
-throw() {
- return errorCode == 28 || errorCode == 3113 || errorCode == 3114 || errorCode == 1012 || errorCode == 12570 || errorCode == 12571;
-}