static char * ocilibGetError( HB_ERRCODE * pErrCode ) { OCI_Error * err = OCI_GetLastError(); char * szRet; int iNativeErr; if( err ) { PHB_ITEM pRet = M_HB_ITEMPUTSTR( NULL, OCI_ErrorGetString( err ) ); szRet = hb_strdup( hb_itemGetCPtr( pRet ) ); hb_itemRelease( pRet ); iNativeErr = OCI_ErrorGetOCICode( err ); } else { szRet = hb_strdup( "Unable to get error message" ); iNativeErr = 9999; } if( pErrCode ) *pErrCode = ( HB_ERRCODE ) iNativeErr; return szRet; }
int ociw_error_info(db_wrap * self, char const ** dest, size_t * len, int * errCode) { if (! self) return DB_WRAP_E_BAD_ARG; #if 1 /* workaround for per-connection error info not being available to us for reasons which haven't been fully determined. This does NOT provide the exact same semantics as the underlying driver, which appears to re-set the error information on each call into the API. Our problem appears to be that we sometimes have several OCI calls before we check the error state, and the error state is gone by the time we can get around to fetching it. */ if (dest) *dest = ociw_error_info_kludge.errorString; if (len) *len = ociw_error_info_kludge.errorString ? strlen(ociw_error_info_kludge.errorString) : 0; if (errCode) *errCode = ociw_error_info_kludge.ociCode; #else OCI_Error * err = OCI_GetLastError(); if (! err) { if (dest) *dest = NULL; if (len) *len = 0; if (errCode) *errCode = 0; return 0; } char const * msg = OCI_ErrorGetString(err); if (dest) *dest = msg; if (len) *len = msg ? strlen(msg) : 0; if (errCode) *errCode = OCI_ErrorGetOCICode(err); #endif return 0; }
void raise_ocierror() { OCI_Error *err = OCI_GetLastError(); if (err) { perror(OCI_ErrorGetString(err)); exit(1); } }
void long_oracle_call(OCI_Thread *thread, void *data) { clock_t t_start = clock(); int err_code = 0; if (!OCI_ExecuteStmt((OCI_Statement *)data, "begin dbms_lock.sleep(10); end;")) { OCI_Error *err = OCI_GetLastError(); if (err) { err_code = OCI_ErrorGetOCICode(err); } } printf("call duration %d, expected oracle error is 1013, got %d", clock() - t_start, err_code); }