From c89b8a38de20c00bb6d9d822f7f027ce9fcf51d8 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Mon, 24 Nov 2014 18:26:44 +0100 Subject: [PATCH] - Enhance the implementation of ODBC tables when using scrollable cursor modified: storage/connect/odbconn.cpp storage/connect/odbconn.h storage/connect/tabodbc.cpp --- storage/connect/odbconn.cpp | 22 ++++++++++++---------- storage/connect/odbconn.h | 2 +- storage/connect/tabodbc.cpp | 8 +++----- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/storage/connect/odbconn.cpp b/storage/connect/odbconn.cpp index b68b4648616..e614980a57a 100644 --- a/storage/connect/odbconn.cpp +++ b/storage/connect/odbconn.cpp @@ -2439,29 +2439,31 @@ PQRYRES ODBConn::AllocateResult(PGLOBAL g) /***********************************************************************/ /* Restart from beginning of result set */ /***********************************************************************/ -bool ODBConn::Rewind(char *sql, ODBCCOL *tocols) +int ODBConn::Rewind(char *sql, ODBCCOL *tocols) { - RETCODE rc; + int rc, rbuf = -1; if (!m_hstmt) - return false; + return rbuf; if (m_Scrollable) { + SQLULEN crow; + try { - rc = SQLFetchScroll(m_hstmt, SQL_FETCH_ABSOLUTE, 0); + rc = SQLExtendedFetch(m_hstmt, SQL_FETCH_FIRST, 1, &crow, NULL); - if (rc != SQL_NO_DATA_FOUND) - ThrowDBX(rc, "SQLFetchScroll", m_hstmt); + if (!Check(rc)) + ThrowDBX(rc, "SQLExtendedFetch", m_hstmt); + rbuf = (int)crow; } catch(DBX *x) { strcpy(m_G->Message, x->GetErrorMessage(0)); - return true; } // end try/catch - } else if (ExecDirectSQL(sql, tocols) < 0) - return true; + } else if (ExecDirectSQL(sql, tocols) >= 0) + rbuf = 0; - return false; + return rbuf; } // end of Rewind /***********************************************************************/ diff --git a/storage/connect/odbconn.h b/storage/connect/odbconn.h index 13d58488b39..ff8357c4591 100644 --- a/storage/connect/odbconn.h +++ b/storage/connect/odbconn.h @@ -124,7 +124,7 @@ class ODBConn : public BLOCK { forceOdbcDialog = 0x0010}; // Always display ODBC connect dialog int Open(PSZ ConnectString, DWORD Options = 0); - bool Rewind(char *sql, ODBCCOL *tocols); + int Rewind(char *sql, ODBCCOL *tocols); void Close(void); PQRYRES AllocateResult(PGLOBAL g); diff --git a/storage/connect/tabodbc.cpp b/storage/connect/tabodbc.cpp index cb21f33c1b1..6608083f1b4 100644 --- a/storage/connect/tabodbc.cpp +++ b/storage/connect/tabodbc.cpp @@ -130,10 +130,7 @@ bool ODBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) Quoted = GetIntCatInfo("Quoted", 0); Options = ODBConn::noOdbcDialog; //Options = ODBConn::noOdbcDialog | ODBConn::useCursorLib; - - if ((Scrollable = GetBoolCatInfo("Scrollable", false))) - Elemt = 0; // Not compatible with extended fetch - + Scrollable = GetBoolCatInfo("Scrollable", false); Memory = GetBoolCatInfo("Memory", false); Pseudo = 2; // FILID is Ok but not ROWID return false; @@ -775,13 +772,14 @@ bool TDBODBC::OpenDB(PGLOBAL g) if (Memory < 3) { // Method will depend on cursor type - if (Ocp->Rewind(Query, (PODBCCOL)Columns)) { + if ((Rbuf = Ocp->Rewind(Query, (PODBCCOL)Columns)) < 0) { Ocp->Close(); return true; } // endif Rewind } // endif Memory + CurNum = 0; Fpos = 0; return false; } // endif use