#include <odbcDbc.h>
Collaboration diagram for CSqlOdbcDbc:
Definition at line 19 of file odbcDbc.h.
SQLRETURN CSqlOdbcDbc::chkStateForSQLConnect | ( | void | ) |
Definition at line 52 of file odbcState.cxx.
References C0, C1, C2, C3, C4, C5, C6, err_, ERROR_CONNINUSE, CSqlOdbcError::set(), SQL_ERROR, SQL_SUCCESS, and state_.
Referenced by SQLConnect().
00053 { 00054 switch( state_ ) 00055 { 00056 case C0: 00057 case C1: 00058 case C2: break; 00059 case C3: 00060 case C4: 00061 case C5: 00062 case C6: err_.set( ERROR_CONNINUSE ); 00063 return( SQL_ERROR ); 00064 } 00065 return( SQL_SUCCESS ); 00066 }
Here is the call graph for this function:
Here is the caller graph for this function:
SQLRETURN CSqlOdbcDbc::chkStateForSQLDisconnect | ( | void | ) |
Definition at line 67 of file odbcState.cxx.
References C0, C1, C2, C3, C4, C5, C6, err_, ERROR_CONNOTOPEN, ERROR_INVTRANSTATE, CSqlOdbcError::set(), SQL_ERROR, SQL_SUCCESS, and state_.
Referenced by SQLDisconnect().
00068 { 00069 switch( state_ ) 00070 { 00071 case C0: 00072 case C1: 00073 case C2: err_.set( ERROR_CONNOTOPEN ); 00074 return( SQL_ERROR ); 00075 case C3: 00076 case C4: 00077 case C5: break; 00078 case C6: err_.set( ERROR_INVTRANSTATE ); 00079 return( SQL_ERROR ); 00080 } 00081 return( SQL_SUCCESS ); 00082 }
Here is the call graph for this function:
Here is the caller graph for this function:
SQLRETURN CSqlOdbcDbc::chkStateForSQLEndTran | ( | void | ) |
Definition at line 83 of file odbcState.cxx.
References C0, C1, C2, C3, C4, C5, C6, err_, ERROR_NOTOPENED, CSqlOdbcError::set(), SQL_ERROR, SQL_SUCCESS, and state_.
Referenced by SQLEndTran().
00084 { 00085 switch( state_ ) 00086 { 00087 case C0: 00088 case C1: 00089 case C2: 00090 case C3: err_.set( ERROR_NOTOPENED ); 00091 return( SQL_ERROR ); 00092 case C4: 00093 case C5: 00094 case C6: break; 00095 } 00096 return( SQL_SUCCESS ); 00097 }
Here is the call graph for this function:
Here is the caller graph for this function:
SQLRETURN CSqlOdbcDbc::chkStateForSQLFreeHandle | ( | void | ) |
Definition at line 37 of file odbcState.cxx.
References C0, C1, C2, C3, C4, C5, C6, err_, ERROR_FUNCSEQ, CSqlOdbcError::set(), SQL_ERROR, SQL_SUCCESS, and state_.
00038 { 00039 switch( state_ ) 00040 { 00041 case C0: 00042 case C1: 00043 case C2: break; 00044 case C3: 00045 case C4: 00046 case C5: 00047 case C6: err_.set( ERROR_FUNCSEQ ); 00048 return( SQL_ERROR ); 00049 } 00050 return( SQL_SUCCESS ); 00051 }
Here is the call graph for this function:
SQLRETURN CSqlOdbcDbc::chkStateForSQLSetConnectAttr | ( | void | ) |
Definition at line 98 of file odbcState.cxx.
References C0, C1, C2, C3, C4, C5, C6, err_, ERROR_FUNCSEQ, CSqlOdbcError::set(), SQL_ERROR, SQL_SUCCESS, and state_.
00099 { 00100 switch( state_ ) 00101 { 00102 case C0: 00103 case C1: 00104 case C2: 00105 case C3: 00106 case C4: 00107 case C5: break; 00108 case C6: err_.set( ERROR_FUNCSEQ ); 00109 return( SQL_ERROR ); 00110 } 00111 return( SQL_SUCCESS ); 00112 }
Here is the call graph for this function:
Definition at line 34 of file odbcDbc.cxx.
References C2, E2, ERROR_FUNCSEQ, ERROR_MEMALLOC, globalError, isValidHandle(), CSqlOdbcError::printStr(), CSqlOdbcError::set(), SQL_ERROR, SQL_HANDLE_ENV, SQL_INVALID_HANDLE, SQL_OV_ODBC3, and SQL_SUCCESS.
Referenced by SQLAllocConnect(), and SQLAllocHandle().
00037 { 00038 00039 CSqlOdbcEnv *inputEnv = (CSqlOdbcEnv*) inputHandle; 00040 00041 if( isValidHandle( inputEnv, SQL_HANDLE_ENV ) != SQL_SUCCESS ) 00042 return( SQL_INVALID_HANDLE ); 00043 00044 // Stop if odbcVersion not set. 00045 if( inputEnv->odbcVersion_ == 0 ) 00046 { 00047 inputEnv->err_.set( ERROR_FUNCSEQ ); 00048 return( SQL_ERROR ); 00049 } 00050 00051 // Allocate Connection object. 00052 *outputHandle = (SQLHANDLE*) new CSqlOdbcDbc; 00053 if( *outputHandle == NULL ) 00054 { 00055 globalError.set( ERROR_MEMALLOC ); 00056 globalError.printStr( SQL_OV_ODBC3 ); 00057 return( SQL_ERROR ); 00058 } 00059 00060 // Initialize relation b/w Env and Dbc 00061 inputEnv->dbcList_.insert( inputEnv->dbcList_.begin(), (CSqlOdbcDbc*) *outputHandle ); 00062 inputEnv->state_ = E2; 00063 ((CSqlOdbcDbc*) *outputHandle)->parentEnv_ = inputEnv; 00064 ((CSqlOdbcDbc*) *outputHandle)->state_ = C2; 00065 00066 return( SQL_SUCCESS ); 00067 }
Here is the call graph for this function:
Here is the caller graph for this function:
SQLRETURN CSqlOdbcDbc::SQLConnect | ( | SQLCHAR * | serverName, | |
SQLSMALLINT | len1, | |||
SQLCHAR * | user, | |||
SQLSMALLINT | len2, | |||
SQLCHAR * | pass, | |||
SQLSMALLINT | len3 | |||
) |
Definition at line 147 of file odbcDbc.cxx.
References accessMode_, AbsSqlConnection::beginTrans(), C4, chkStateForSQLConnect(), AbsSqlConnection::connect(), SqlFactory::createConnection(), CSql, CSqlAdapter, CSqlGateway, curAccessMode_, curIsolationLevel_, err_, ERROR_BUFLEN, ERROR_CONNINUSE, ERROR_CONNREJCTD, ERROR_INVTRANSTATE, fsqlConn_, isolationLevel_, mode_, NO_ERR, OK, CSqlOdbcError::set(), SQL_ERROR, SQL_NTS, SQL_SUCCESS, and state_.
00154 { 00155 int rc; 00156 char *hostName,*portNo; 00157 // Start with NO_ERR 00158 err_.set( NO_ERR ); 00159 00160 // Can we proceed ? 00161 if( chkStateForSQLConnect() != SQL_SUCCESS ) 00162 return( SQL_ERROR ); 00163 00164 // Invalid Buffer Length. 00165 if( (len1 < 0 && len1 != SQL_NTS) || (len2 < 0 && len2 != SQL_NTS) || (len2 < 0 && len2 != SQL_NTS) ) 00166 { 00167 err_.set( ERROR_BUFLEN ); 00168 return( SQL_ERROR ); 00169 } 00170 if (fsqlConn_ != NULL) 00171 { 00172 err_.set( ERROR_CONNINUSE); 00173 return ( SQL_ERROR ); 00174 } 00175 if (strcasecmp((char*)serverName, "gateway") == 0) 00176 { 00177 fsqlConn_ = SqlFactory::createConnection(CSqlGateway); 00178 mode_ = 2; 00179 }else if (strcasecmp((char*)serverName, "adapter") == 0){ 00180 fsqlConn_ = SqlFactory::createConnection(CSqlAdapter); 00181 mode_ = 3; 00182 }else{ 00183 fsqlConn_ = SqlFactory::createConnection(CSql); 00184 mode_ = 1; 00185 } 00186 00187 rc = fsqlConn_->connect( (char*) user, (char*) pass ); 00188 if( rc != OK ) 00189 { 00190 err_.set( ERROR_CONNREJCTD); 00191 return( SQL_ERROR ); 00192 } 00193 rc = fsqlConn_->beginTrans( isolationLevel_ ); 00194 if( rc != OK ) 00195 { 00196 err_.set( ERROR_INVTRANSTATE ); 00197 return( SQL_ERROR ); 00198 } 00199 curAccessMode_ = accessMode_; 00200 curIsolationLevel_ = isolationLevel_; 00201 00202 // Update Dbc state 00203 state_ = C4; 00204 00205 return( SQL_SUCCESS ); 00206 }
Here is the call graph for this function:
SQLRETURN CSqlOdbcDbc::SQLDisconnect | ( | ) |
Definition at line 218 of file odbcDbc.cxx.
References C2, chkStateForSQLDisconnect(), AbsSqlConnection::commit(), AbsSqlConnection::disconnect(), err_, fsqlConn_, NO_ERR, OK, CSqlOdbcError::set(), SQL_ERROR, SQL_SUCCESS, CSqlOdbcStmt::SQLFreeHandle(), state_, and stmtList_.
00219 { 00220 SQLRETURN rc; 00221 00222 // Start with NO_ERR 00223 err_.set( NO_ERR ); 00224 00225 // Can we proceed ? 00226 if( chkStateForSQLDisconnect() != SQL_SUCCESS ) 00227 return( SQL_ERROR ); 00228 00229 // Free all stmts 00230 while( stmtList_.size() != 0 ) 00231 { 00232 rc = CSqlOdbcStmt::SQLFreeHandle( stmtList_[0] ); 00233 // This free's the stmt and removes element from stmtList_. 00234 if( rc != OK ) 00235 return( SQL_ERROR ); 00236 } 00237 00238 // Commit the transaction 00239 if( fsqlConn_->commit() != OK ) 00240 return( SQL_ERROR ); 00241 00242 // Disconnect 00243 if( fsqlConn_->disconnect() != OK ) 00244 return( SQL_ERROR ); 00245 00246 delete fsqlConn_; 00247 fsqlConn_ = NULL; 00248 // Change the state of Dbc 00249 state_ = C2; 00250 00251 return( SQL_SUCCESS ); 00252 }
Here is the call graph for this function:
SQLRETURN CSqlOdbcDbc::SQLEndTran | ( | SQLSMALLINT | completionType | ) |
Definition at line 254 of file odbcDbc.cxx.
References AbsSqlConnection::beginTrans(), C4, C5, C6, chkStateForSQLEndTran(), AbsSqlConnection::commit(), curIsolationLevel_, err_, ERROR_OPTRANGE, fsqlConn_, NO_ERR, OK, AbsSqlConnection::rollback(), CSqlOdbcError::set(), SQL_CLOSE, SQL_COMMIT, SQL_ERROR, SQL_ROLLBACK, SQL_SUCCESS, state_, and stmtList_.
Referenced by CSqlOdbcStmt::SQLExecute(), and SQLSetConnectAttr().
00256 { 00257 SQLRETURN rc; 00258 00259 // Start with NO_ERR 00260 err_.set( NO_ERR ); 00261 00262 // Can we proceed ? 00263 if( chkStateForSQLEndTran() != SQL_SUCCESS ) 00264 return( SQL_ERROR ); 00265 00266 // Stop if no transaction is started. 00267 if( state_ != C6 ) 00268 return( SQL_SUCCESS ); 00269 00270 // Close cursors of all the statements 00271 std::vector<CSqlOdbcStmt*>::iterator iter; 00272 iter = stmtList_.begin(); 00273 while( iter != stmtList_.end() ) 00274 { 00275 (*iter)->SQLFreeHandle( SQL_CLOSE ); 00276 iter++; 00277 } 00278 00279 // Finish transaction 00280 switch( completionType ) 00281 { 00282 case SQL_COMMIT: 00283 00284 if( fsqlConn_->commit() != OK ) 00285 return( SQL_ERROR ); 00286 00287 if( fsqlConn_->beginTrans( curIsolationLevel_ ) != OK ) 00288 return( SQL_ERROR ); 00289 00290 break; 00291 00292 case SQL_ROLLBACK: 00293 if( fsqlConn_->rollback() != OK ) 00294 return( SQL_ERROR ); 00295 00296 rc = fsqlConn_->beginTrans( curIsolationLevel_ ); 00297 break; 00298 00299 default: err_.set( ERROR_OPTRANGE ); 00300 return( SQL_ERROR ); 00301 } 00302 00303 // Had statements ? 00304 if( stmtList_.size() == 0 ) 00305 state_ = C4; 00306 else 00307 state_ = C5; 00308 00309 return( SQL_SUCCESS ); 00310 }
Here is the call graph for this function:
Here is the caller graph for this function:
Definition at line 75 of file odbcDbc.cxx.
References E1, isValidHandle(), SQL_ERROR, SQL_HANDLE_DBC, SQL_INVALID_HANDLE, and SQL_SUCCESS.
Referenced by SQLFreeConnect(), and SQLFreeHandle().
00077 { 00078 CSqlOdbcDbc *inputDbc = (CSqlOdbcDbc*) inputHandle; 00079 00080 // Validate handle 00081 if( isValidHandle( inputDbc, SQL_HANDLE_DBC ) != SQL_SUCCESS ) 00082 return( SQL_INVALID_HANDLE ); 00083 00084 // Check whether we can proceed. 00085 if( inputDbc->chkStateForSQLFreeHandle() != SQL_SUCCESS ) 00086 return( SQL_ERROR ); 00087 00088 // Remove Dbc from Parent Env. 00089 std::vector<CSqlOdbcDbc*>::iterator iter; 00090 iter = inputDbc->parentEnv_->dbcList_.begin(); 00091 while( iter != inputDbc->parentEnv_->dbcList_.end() ) 00092 { 00093 if( *iter == inputDbc ) 00094 { 00095 inputDbc->parentEnv_->dbcList_.erase( iter ); 00096 break; 00097 } 00098 iter++; 00099 } 00100 if( inputDbc->parentEnv_->dbcList_.size() == 0 ) 00101 inputDbc->parentEnv_->state_ = E1; 00102 00103 inputDbc->handleType_ = -1; // Make object invalid. 00104 delete inputDbc; // Delete Dbc. 00105 00106 return( SQL_SUCCESS ); 00107 }
Here is the call graph for this function:
Here is the caller graph for this function:
SQLRETURN CSqlOdbcDbc::SQLGetConnectAttr | ( | SQLINTEGER | attribute, | |
SQLPOINTER | value, | |||
SQLINTEGER | bufferLength, | |||
SQLINTEGER * | stringLength | |||
) |
Definition at line 403 of file odbcDbc.cxx.
References accessMode_, ACCESSMODE_READ_ONLY, ACCESSMODE_READ_WRITE, autoCommit_, err_, ERROR_OPTRANGE, isolationLevel_, NO_ERR, READ_COMMITTED, READ_REPEATABLE, READ_UNCOMMITTED, CSqlOdbcError::set(), SQL_ATTR_ACCESS_MODE, SQL_ATTR_AUTOCOMMIT, SQL_ATTR_TXN_ISOLATION, SQL_DEFAULT_TXN_ISOLATION, SQL_ERROR, SQL_MODE_READ_ONLY, SQL_MODE_READ_WRITE, SQL_SUCCESS, SQL_TXN_READ_COMMITTED, SQL_TXN_READ_UNCOMMITTED, and SQL_TXN_REPEATABLE_READ.
00408 { 00409 // Start with NO_ERR 00410 err_.set( NO_ERR ); 00411 00412 switch( attribute ) 00413 { 00414 case SQL_ATTR_ACCESS_MODE: 00415 // Get ODBC Access Mode 00416 if( accessMode_ == ACCESSMODE_READ_ONLY ) 00417 *((SQLUINTEGER*) value) = SQL_MODE_READ_ONLY; 00418 else if( accessMode_ == ACCESSMODE_READ_WRITE ) 00419 *((SQLUINTEGER*) value) = SQL_MODE_READ_WRITE; 00420 else 00421 return( SQL_ERROR ); 00422 00423 break; 00424 case SQL_DEFAULT_TXN_ISOLATION: 00425 case SQL_ATTR_TXN_ISOLATION: 00426 // validate 'value' 00427 if( (SQLUINTEGER) isolationLevel_ == READ_UNCOMMITTED ) 00428 *((SQLUINTEGER*) value) = SQL_TXN_READ_UNCOMMITTED; 00429 else if( (SQLUINTEGER) isolationLevel_ == READ_COMMITTED ) 00430 *((SQLUINTEGER*) value) = SQL_TXN_READ_COMMITTED; 00431 else if( (SQLUINTEGER) isolationLevel_ == READ_REPEATABLE ) 00432 *((SQLUINTEGER*) value) = SQL_TXN_REPEATABLE_READ; 00433 // else if( (SQLUINTEGER) isolationLevel_ == SERIALIZABLE ) 00434 // *((SQLUINTEGER*) value) = SQL_TXN_SERIALIZABLE; 00435 else 00436 return( SQL_ERROR ); 00437 00438 break; 00439 case SQL_ATTR_AUTOCOMMIT: 00440 *((SQLUINTEGER*) value) = autoCommit_; 00441 break; 00442 00443 default: err_.set( ERROR_OPTRANGE ); 00444 return( SQL_ERROR ); 00445 } 00446 00447 return( SQL_SUCCESS ); 00448 }
Here is the call graph for this function:
SQLRETURN CSqlOdbcDbc::SQLSetConnectAttr | ( | SQLINTEGER | attribute, | |
SQLPOINTER | value, | |||
SQLINTEGER | stringLength | |||
) |
Definition at line 333 of file odbcDbc.cxx.
References accessMode_, ACCESSMODE_READ_ONLY, ACCESSMODE_READ_WRITE, autoCommit_, C6, err_, ERROR_OPTRANGE, isolationLevel_, NO_ERR, READ_COMMITTED, READ_REPEATABLE, READ_UNCOMMITTED, CSqlOdbcError::set(), SQL_ATTR_ACCESS_MODE, SQL_ATTR_AUTOCOMMIT, SQL_ATTR_TXN_ISOLATION, SQL_COMMIT, SQL_DEFAULT_TXN_ISOLATION, SQL_ERROR, SQL_MODE_READ_ONLY, SQL_MODE_READ_WRITE, SQL_SUCCESS, SQL_TXN_READ_COMMITTED, SQL_TXN_READ_UNCOMMITTED, SQL_TXN_REPEATABLE_READ, SQLEndTran(), and state_.
00337 { 00338 // Start with NO_ERR 00339 err_.set( NO_ERR ); 00340 00341 switch( attribute ) 00342 { 00343 case SQL_ATTR_ACCESS_MODE: 00344 // validate 'value' 00345 if( (SQLUINTEGER) value == SQL_MODE_READ_ONLY ) 00346 accessMode_ = ACCESSMODE_READ_ONLY; 00347 else if( (SQLUINTEGER) value == SQL_MODE_READ_WRITE ) 00348 accessMode_ = ACCESSMODE_READ_WRITE; 00349 else 00350 return( SQL_ERROR ); 00351 00352 break; 00353 case SQL_DEFAULT_TXN_ISOLATION: 00354 case SQL_ATTR_TXN_ISOLATION: 00355 // validate 'value' 00356 if( (SQLUINTEGER) value == SQL_TXN_READ_UNCOMMITTED ) 00357 isolationLevel_ = READ_UNCOMMITTED; 00358 else if( (SQLUINTEGER) value == SQL_TXN_READ_COMMITTED ) 00359 isolationLevel_ = READ_COMMITTED; 00360 else if( (SQLUINTEGER) value == SQL_TXN_REPEATABLE_READ ) 00361 isolationLevel_ = READ_REPEATABLE; 00362 // else if( (SQLUINTEGER) value == SQL_TXN_SERIALIZABLE ) 00363 // isolationLevel_ = SERIALIZABLE; 00364 else 00365 return( SQL_ERROR ); 00366 00367 break; 00368 case SQL_ATTR_AUTOCOMMIT: 00369 autoCommit_ = (SQLUINTEGER) value; 00370 if( state_ == C6 ) 00371 SQLEndTran( SQL_COMMIT ); 00372 break; 00373 00374 default: err_.set( ERROR_OPTRANGE ); 00375 return( SQL_ERROR ); 00376 } 00377 00378 return( SQL_SUCCESS ); 00379 }
Here is the call graph for this function:
Definition at line 38 of file odbcDbc.h.
Referenced by SQLConnect(), SQLGetConnectAttr(), and SQLSetConnectAttr().
Definition at line 48 of file odbcDbc.h.
Referenced by CSqlOdbcStmt::SQLExecute(), SQLGetConnectAttr(), and SQLSetConnectAttr().
std::vector<CSqlOdbcDesc*> CSqlOdbcDbc::descList_ |
Definition at line 26 of file odbcDbc.h.
Referenced by chkStateForSQLConnect(), chkStateForSQLDisconnect(), chkStateForSQLEndTran(), chkStateForSQLFreeHandle(), chkStateForSQLSetConnectAttr(), SQLConnect(), SQLDisconnect(), SQLEndTran(), SQLGetConnectAttr(), and SQLSetConnectAttr().
Definition at line 32 of file odbcDbc.h.
Referenced by SQLConnect(), SQLDisconnect(), SQLEndTran(), and CSqlOdbcStmt::SQLPrepare().
Definition at line 42 of file odbcDbc.h.
Referenced by SQLConnect(), SQLGetConnectAttr(), and SQLSetConnectAttr().
Definition at line 33 of file odbcDbc.h.
Referenced by SQLConnect(), and CSqlOdbcStmt::SQLPrepare().
Definition at line 28 of file odbcDbc.h.
Referenced by chkStateForSQLConnect(), chkStateForSQLDisconnect(), chkStateForSQLEndTran(), chkStateForSQLFreeHandle(), chkStateForSQLSetConnectAttr(), SQLConnect(), SQLDisconnect(), SQLEndTran(), CSqlOdbcStmt::SQLExecute(), and SQLSetConnectAttr().
std::vector<CSqlOdbcStmt*> CSqlOdbcDbc::stmtList_ |
Definition at line 30 of file odbcDbc.h.
Referenced by SQLDisconnect(), SQLEndTran(), and CSqlOdbcStmt::SQLSetCursorName().