X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6919c53fd2584020b83faf9908a249bbec964a0e..1f897d251f5428c34f9c742887b1a28b4aaa1740:/src/common/dbtable.cpp diff --git a/src/common/dbtable.cpp b/src/common/dbtable.cpp index 1e603781ed..edf1a0ce1c 100644 --- a/src/common/dbtable.cpp +++ b/src/common/dbtable.cpp @@ -461,31 +461,31 @@ bool wxTable::getRec(UWORD fetchType) { RETCODE retcode; -#if !wxODBC_FWD_ONLY_CURSORS - - // Fetch the NEXT, PREV, FIRST or LAST record, depending on fetchType - UDWORD cRowsFetched; - UWORD rowStatus; - -// if ((retcode = SQLExtendedFetch(hstmt, fetchType, 0, &cRowsFetched, &rowStatus)) != SQL_SUCCESS) - retcode = SQLExtendedFetch(hstmt, fetchType, 0, &cRowsFetched, &rowStatus); - if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO) - if (retcode == SQL_NO_DATA_FOUND) - return(FALSE); - else - return(pDb->DispAllErrors(henv, hdbc, hstmt)); -#else + if (!pDb->FwdOnlyCursors()) + { + // Fetch the NEXT, PREV, FIRST or LAST record, depending on fetchType + UDWORD cRowsFetched; + UWORD rowStatus; - // Fetch the next record from the record set - retcode = SQLFetch(hstmt); - if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO) + retcode = SQLExtendedFetch(hstmt, fetchType, 0, &cRowsFetched, &rowStatus); + if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO) + if (retcode == SQL_NO_DATA_FOUND) + return(FALSE); + else + return(pDb->DispAllErrors(henv, hdbc, hstmt)); + } + else { - if (retcode == SQL_NO_DATA_FOUND) - return(FALSE); - else - return(pDb->DispAllErrors(henv, hdbc, hstmt)); + // Fetch the next record from the record set + retcode = SQLFetch(hstmt); + if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO) + { + if (retcode == SQL_NO_DATA_FOUND) + return(FALSE); + else + return(pDb->DispAllErrors(henv, hdbc, hstmt)); + } } -#endif // Completed successfully return(TRUE); @@ -660,6 +660,54 @@ bool wxTable::QueryOnKeyFields(bool forUpdate, bool distinct) } // wxTable::QueryOnKeyFields() +/********** wxTable::GetPrev() **********/ +bool wxTable::GetPrev(void) +{ + if (pDb->FwdOnlyCursors()) + { + wxFAIL_MSG(wxT("GetPrev()::Backward scrolling cursors are not enabled for this instance of wxTable")); + return FALSE; + } + else + return(getRec(SQL_FETCH_PRIOR)); +} // wxTable::GetPrev() + +/********** wxTable::operator-- **********/ +bool wxTable::operator--(int) +{ + if (pDb->FwdOnlyCursors()) + { + wxFAIL_MSG(wxT("operator--:Backward scrolling cursors are not enabled for this instance of wxTable")); + return FALSE; + } + else + return(getRec(SQL_FETCH_PRIOR)); +} // wxTable::operator-- + +/********** wxTable::GetFirst() **********/ +bool wxTable::GetFirst(void) +{ + if (pDb->FwdOnlyCursors()) + { + wxFAIL_MSG(wxT("GetFirst():Backward scrolling cursors are not enabled for this instance of wxTable")); + return FALSE; + } + else + return(getRec(SQL_FETCH_FIRST)); +} // wxTable::GetFirst() + +/********** wxTable::GetLast() **********/ +bool wxTable::GetLast(void) +{ + if (pDb->FwdOnlyCursors()) + { + wxFAIL_MSG(wxT("GetLast()::Backward scrolling cursors are not enabled for this instance of wxTable")); + return FALSE; + } + else + return(getRec(SQL_FETCH_LAST)); +} // wxTable::GetLast() + /********** wxTable::GetSelectStmt() **********/ void wxTable::GetSelectStmt(char *pSqlStmt, int typeOfSelect, bool distinct) {