CSqlOdbcError Class Reference

#include <odbcError.h>


Public Member Functions

SQLRETURN SQLGetDiagRec (SQLHANDLE hdl, SQLCHAR *sqlState, SQLINTEGER *csqlErrCode, SQLCHAR *Msg, SQLSMALLINT bufLen, SQLSMALLINT *textLen)
 CSqlOdbcError (long hdlType)
void set (long err)
SQLRETURN printStr (SQLUINTEGER odbcVersion)

Static Public Member Functions

static void printDbg (char *msg)

Data Fields

int hdlType
SQLINTEGER csqlErrCode


Detailed Description

Definition at line 4 of file odbcError.h.


Constructor & Destructor Documentation

CSqlOdbcError::CSqlOdbcError ( long  hdlType  ) 

Definition at line 12 of file odbcError.cxx.

00012                                               : 
00013     csqlErrCode ( OK ), 
00014     hdlType( handleType ) 
00015 {}


Member Function Documentation

void CSqlOdbcError::printDbg ( char *  msg  )  [static]

Definition at line 150 of file odbcError.cxx.

Referenced by CSqlOdbcStmt::SQLSetStmtAttr().

00151 {
00152 #ifdef DEBUG_INFO
00153     fprintf( stderr, "ODBC DBG: %s\n", msg );
00154 #endif
00155     return;
00156 }

Here is the caller graph for this function:

SQLRETURN CSqlOdbcError::printStr ( SQLUINTEGER  odbcVersion  ) 

Definition at line 25 of file odbcError.cxx.

References csqlErrCode, ERROR_ENDOFTABLE, errorInfoTable_2x, errorInfoTable_3x, SQL_ERROR, SQL_OV_ODBC3, and SQL_SUCCESS.

Referenced by isValidHandle(), set(), CSqlOdbcStmt::SQLAllocHandle(), CSqlOdbcEnv::SQLAllocHandle(), CSqlOdbcDbc::SQLAllocHandle(), SQLAllocHandle(), SQLEndTran(), and SQLFreeHandle().

00026 {
00027     ErrorInfo_t *errorInfoTbl;
00028     int code = 0, i = 0;
00029     
00030 #ifndef DEBUG_INFO
00031     return( SQL_SUCCESS );
00032 #endif
00033 
00034     // Select error table.
00035     if( odbcVersion >= SQL_OV_ODBC3 )
00036         errorInfoTbl = errorInfoTable_3x;
00037     else
00038         errorInfoTbl = errorInfoTable_2x;
00039 
00040     // Search in table.
00041     while( errorInfoTbl[i].csqlErrCode != csqlErrCode && errorInfoTbl[i].csqlErrCode != ERROR_ENDOFTABLE ) i++;
00042 
00043     // Print details, if found
00044     if( errorInfoTbl[i].csqlErrCode == csqlErrCode )
00045     {
00046         fprintf( stderr, "[NativeCode: %ld][SqlState: %s][Message: %s].\n", 
00047             csqlErrCode, 
00048             (char*) errorInfoTbl[i].sqlState,
00049             (char*) errorInfoTbl[i].sqlMessage );
00050 
00051         return( SQL_SUCCESS );
00052     }
00053 
00054     return( SQL_ERROR );
00055 }

Here is the caller graph for this function:

void CSqlOdbcError::set ( long  err  ) 

Definition at line 17 of file odbcError.cxx.

References csqlErrCode, OK, printStr(), and SQL_OV_ODBC3.

Referenced by CSqlOdbcStmt::chkStateForSQLBindCol(), CSqlOdbcStmt::chkStateForSQLBindParameter(), CSqlOdbcStmt::chkStateForSQLCloseCursor(), CSqlOdbcDbc::chkStateForSQLConnect(), CSqlOdbcStmt::chkStateForSQLDescribeCol(), CSqlOdbcStmt::chkStateForSQLDescribeParam(), CSqlOdbcDbc::chkStateForSQLDisconnect(), CSqlOdbcDbc::chkStateForSQLEndTran(), CSqlOdbcStmt::chkStateForSQLExecDirect(), CSqlOdbcStmt::chkStateForSQLExecute(), CSqlOdbcStmt::chkStateForSQLFetch(), CSqlOdbcStmt::chkStateForSQLFreeHandle(), CSqlOdbcDbc::chkStateForSQLFreeHandle(), CSqlOdbcEnv::chkStateForSQLFreeHandle(), CSqlOdbcStmt::chkStateForSQLFreeStmt(), CSqlOdbcStmt::chkStateForSQLGetCursorName(), CSqlOdbcStmt::chkStateForSQLNumParams(), CSqlOdbcStmt::chkStateForSQLNumResultCols(), CSqlOdbcStmt::chkStateForSQLPrepare(), CSqlOdbcStmt::chkStateForSQLRowCount(), CSqlOdbcDbc::chkStateForSQLSetConnectAttr(), CSqlOdbcStmt::chkStateForSQLSetCursorName(), CSqlOdbcEnv::chkStateForSQLSetEnvAttr(), isValidHandle(), CSqlOdbcStmt::SQLAllocHandle(), CSqlOdbcEnv::SQLAllocHandle(), CSqlOdbcDbc::SQLAllocHandle(), SQLAllocHandle(), CSqlOdbcStmt::SQLBindCol(), CSqlOdbcStmt::SQLBindParameter(), CSqlOdbcStmt::SQLCloseCursor(), CSqlOdbcStmt::SQLColAttribute(), CSqlOdbcDbc::SQLConnect(), CSqlOdbcStmt::SQLDescribeCol(), CSqlOdbcStmt::SQLDescribeParam(), CSqlOdbcDbc::SQLDisconnect(), CSqlOdbcEnv::SQLEndTran(), CSqlOdbcDbc::SQLEndTran(), SQLEndTran(), CSqlOdbcStmt::SQLExecute(), CSqlOdbcStmt::SQLFetch(), SQLFreeHandle(), CSqlOdbcStmt::SQLFreeStmt(), CSqlOdbcDbc::SQLGetConnectAttr(), CSqlOdbcStmt::SQLGetCursorName(), CSqlOdbcEnv::SQLGetEnvAttr(), CSqlOdbcStmt::SQLNumParams(), CSqlOdbcStmt::SQLNumResultCols(), CSqlOdbcStmt::SQLPrepare(), CSqlOdbcStmt::SQLRowCount(), CSqlOdbcDbc::SQLSetConnectAttr(), CSqlOdbcStmt::SQLSetCursorName(), and CSqlOdbcEnv::SQLSetEnvAttr().

00018 { 
00019     csqlErrCode = err; 
00020     
00021     if( err != OK );
00022         printStr( SQL_OV_ODBC3 ); 
00023 }

Here is the call graph for this function:

Here is the caller graph for this function:

SQLRETURN CSqlOdbcError::SQLGetDiagRec ( SQLHANDLE  hdl,
SQLCHAR sqlState,
SQLINTEGER csqlErrCode,
SQLCHAR Msg,
SQLSMALLINT  bufLen,
SQLSMALLINT textLen 
)

Definition at line 98 of file odbcError.cxx.

References csqlErrCode, errorInfoTable_2x, errorInfoTable_3x, hdlType, OK, SQL_ERROR, SQL_HANDLE_DBC, SQL_HANDLE_ENV, SQL_HANDLE_STMT, SQL_NO_DATA_FOUND, SQL_OV_ODBC3, and SQL_SUCCESS.

00105 {
00106     ErrorInfo_t *errorInfoTbl;
00107     int code = 0, i = 0;
00108     SQLUINTEGER odbcVersion;
00109     
00110     // Get ODBC Version
00111     switch( hdlType )
00112     {
00113         case SQL_HANDLE_ENV:
00114             odbcVersion = ((CSqlOdbcEnv*) handle)->odbcVersion_; break;
00115         case SQL_HANDLE_DBC:
00116             odbcVersion = ((CSqlOdbcDbc*) handle)->parentEnv_->odbcVersion_; break;
00117         case SQL_HANDLE_STMT:
00118             odbcVersion = ((CSqlOdbcStmt*) handle)->parentDbc_->parentEnv_->odbcVersion_; break;
00119         default:
00120             return( SQL_ERROR );
00121     }
00122 
00123     // If No Error
00124     if( csqlErrCode == OK )
00125         return( SQL_NO_DATA_FOUND );
00126 
00127     // Select Error Msg Table based on ODBC Version
00128     if( odbcVersion >= SQL_OV_ODBC3 )
00129         errorInfoTbl = errorInfoTable_3x;
00130     else
00131         errorInfoTbl = errorInfoTable_2x;
00132 
00133     // Search in table
00134     while( errorInfoTbl[i].csqlErrCode != csqlErrCode ) i++;
00135     if( errorInfoTbl[i].csqlErrCode == csqlErrCode )
00136     {
00137         // Fill error info to user space
00138         strcpy( (char*) sqlState, (char*) errorInfoTbl[i].sqlState );
00139         *sqlErrCode = csqlErrCode;
00140         *textLen = (SQLSMALLINT) strlen( (char*) errorInfoTbl[i].sqlMessage );
00141         if( bufLen > *textLen )
00142             bufLen = *textLen + 1;
00143         strncpy( (char*) Msg, (char*) errorInfoTbl[i].sqlMessage, (int) bufLen );
00144         return( SQL_SUCCESS );
00145     }
00146 
00147     return( SQL_ERROR );
00148 }


Field Documentation

SQLINTEGER CSqlOdbcError::csqlErrCode

Definition at line 13 of file odbcError.h.

Referenced by printStr(), set(), CSqlOdbcStmt::SQLFetch(), and SQLGetDiagRec().

int CSqlOdbcError::hdlType

Definition at line 10 of file odbcError.h.

Referenced by SQLGetDiagRec().


The documentation for this class was generated from the following files:
Generated on Mon Jun 9 22:45:31 2008 for csql by  doxygen 1.4.7