CODBC_CursorResult::CODBC_CursorResult(CODBC_LangCmd* cmd) : m_Cmd(cmd) , m_Res(NULL) , m_EOR(false) { try { m_Cmd->Send(); m_EOR = true; while (m_Cmd->HasMoreResults()) { m_Res = m_Cmd->Result(); if (m_Res && m_Res->ResultType() == eDB_RowResult) { m_EOR = false; return; } if (m_Res) { while (m_Res->Fetch()) ; delete m_Res; m_Res = 0; } } } catch (const CDB_Exception& e) { string err_message = "Failed to get the results." + GetDbgInfo(); DATABASE_DRIVER_ERROR_EX( e, err_message, 422010 ); } }
bool CODBC_CursorResultExpl::Fetch(void) { if( m_EOR ) { return false; } try { if (m_Res && m_Res->Fetch()) { return true; } } catch ( const CDB_Exception& ) { delete m_Res; m_Res = 0; } try { // finish this command m_EOR = true; if( m_Res ) { delete m_Res; m_Res = 0; while (m_Cmd->HasMoreResults()) { m_Res = m_Cmd->Result(); if (m_Res) { while (m_Res->Fetch()) { continue; } delete m_Res; m_Res = 0; } } } // send the another "fetch cursor_name" command m_Cmd->Send(); while (m_Cmd->HasMoreResults()) { m_Res = m_Cmd->Result(); if (m_Res && m_Res->ResultType() == eDB_RowResult) { m_EOR = false; return m_Res->Fetch(); } if ( m_Res ) { while (m_Res->Fetch()) { continue; } delete m_Res; m_Res = 0; } } } catch (const CDB_Exception& e) { string err_message = "Failed to fetch the results." + GetDbgInfo(); DATABASE_DRIVER_ERROR_EX( e, err_message, 422011 ); } return false; }
bool CDBL_CursorResult::Fetch() { if ( !GetResultSet() ) return false; try { if (GetResultSet()->Fetch()) return true; } catch (CDB_ClientEx& ex) { if (ex.GetDBErrCode() == 200003) { // ClearResultSet(); m_Res = NULL; } else { DATABASE_DRIVER_ERROR( "Failed to fetch the results." + GetDbgInfo(), 222011 ); } } // try to get next cursor result try { // finish this command // ClearResultSet(); if ( m_Res ) { delete m_Res; m_Res = NULL; } while (m_Cmd->HasMoreResults()) { DumpResultSet(); } // send the another "fetch cursor_name" command m_Cmd->Send(); while (m_Cmd->HasMoreResults()) { SetResultSet( m_Cmd->Result() ); if (GetResultSet() && GetResultSet()->ResultType() == eDB_RowResult) { return GetResultSet()->Fetch(); } FetchAllResultSet(); } } catch ( const CDB_Exception& e ) { DATABASE_DRIVER_ERROR_EX( e, "Failed to fetch the results." + GetDbgInfo(), 222011 ); } return false; }
bool CODBC_CursorResult::Fetch() { if( m_EOR ) { return false; } try { if (m_Res && m_Res->Fetch()) { return true; } } catch ( const CDB_Exception& ) { delete m_Res; m_Res = 0; } try { // finish this command m_EOR = true; if( m_Res ) { delete m_Res; m_Res = 0; while (m_Cmd->HasMoreResults()) { m_Res = m_Cmd->Result(); if (m_Res) { while (m_Res->Fetch()) { continue; } delete m_Res; m_Res = 0; } } } } catch (const CDB_Exception& e) { string err_message = "Failed to fetch the results." + GetDbgInfo(); DATABASE_DRIVER_ERROR_EX( e, err_message, 422011 ); } return false; }
CDBL_CursorResult::CDBL_CursorResult(CDBL_Connection& conn, CDB_LangCmd* cmd) : CDBL_Result(conn, NULL), m_Cmd(cmd), m_Res(0) { try { GetCmd().Send(); while (GetCmd().HasMoreResults()) { SetResultSet( GetCmd().Result() ); if (GetResultSet() && GetResultSet()->ResultType() == eDB_RowResult) { return; } if ( GetResultSet() ) { while (GetResultSet()->Fetch()) continue; ClearResultSet(); } } } catch ( const CDB_Exception& e ) { DATABASE_DRIVER_ERROR_EX( e, "Failed to get the results." + GetDbgInfo(), 222010 ); } }