Skip to content

Commit c89b8a3

Browse files
committed
- Enhance the implementation of ODBC tables when using scrollable cursor
modified: storage/connect/odbconn.cpp storage/connect/odbconn.h storage/connect/tabodbc.cpp
1 parent 6211708 commit c89b8a3

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

storage/connect/odbconn.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2439,29 +2439,31 @@ PQRYRES ODBConn::AllocateResult(PGLOBAL g)
24392439
/***********************************************************************/
24402440
/* Restart from beginning of result set */
24412441
/***********************************************************************/
2442-
bool ODBConn::Rewind(char *sql, ODBCCOL *tocols)
2442+
int ODBConn::Rewind(char *sql, ODBCCOL *tocols)
24432443
{
2444-
RETCODE rc;
2444+
int rc, rbuf = -1;
24452445

24462446
if (!m_hstmt)
2447-
return false;
2447+
return rbuf;
24482448

24492449
if (m_Scrollable) {
2450+
SQLULEN crow;
2451+
24502452
try {
2451-
rc = SQLFetchScroll(m_hstmt, SQL_FETCH_ABSOLUTE, 0);
2453+
rc = SQLExtendedFetch(m_hstmt, SQL_FETCH_FIRST, 1, &crow, NULL);
24522454

2453-
if (rc != SQL_NO_DATA_FOUND)
2454-
ThrowDBX(rc, "SQLFetchScroll", m_hstmt);
2455+
if (!Check(rc))
2456+
ThrowDBX(rc, "SQLExtendedFetch", m_hstmt);
24552457

2458+
rbuf = (int)crow;
24562459
} catch(DBX *x) {
24572460
strcpy(m_G->Message, x->GetErrorMessage(0));
2458-
return true;
24592461
} // end try/catch
24602462

2461-
} else if (ExecDirectSQL(sql, tocols) < 0)
2462-
return true;
2463+
} else if (ExecDirectSQL(sql, tocols) >= 0)
2464+
rbuf = 0;
24632465

2464-
return false;
2466+
return rbuf;
24652467
} // end of Rewind
24662468

24672469
/***********************************************************************/

storage/connect/odbconn.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class ODBConn : public BLOCK {
124124
forceOdbcDialog = 0x0010}; // Always display ODBC connect dialog
125125

126126
int Open(PSZ ConnectString, DWORD Options = 0);
127-
bool Rewind(char *sql, ODBCCOL *tocols);
127+
int Rewind(char *sql, ODBCCOL *tocols);
128128
void Close(void);
129129
PQRYRES AllocateResult(PGLOBAL g);
130130

storage/connect/tabodbc.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,7 @@ bool ODBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
130130
Quoted = GetIntCatInfo("Quoted", 0);
131131
Options = ODBConn::noOdbcDialog;
132132
//Options = ODBConn::noOdbcDialog | ODBConn::useCursorLib;
133-
134-
if ((Scrollable = GetBoolCatInfo("Scrollable", false)))
135-
Elemt = 0; // Not compatible with extended fetch
136-
133+
Scrollable = GetBoolCatInfo("Scrollable", false);
137134
Memory = GetBoolCatInfo("Memory", false);
138135
Pseudo = 2; // FILID is Ok but not ROWID
139136
return false;
@@ -775,13 +772,14 @@ bool TDBODBC::OpenDB(PGLOBAL g)
775772

776773
if (Memory < 3) {
777774
// Method will depend on cursor type
778-
if (Ocp->Rewind(Query, (PODBCCOL)Columns)) {
775+
if ((Rbuf = Ocp->Rewind(Query, (PODBCCOL)Columns)) < 0) {
779776
Ocp->Close();
780777
return true;
781778
} // endif Rewind
782779

783780
} // endif Memory
784781

782+
CurNum = 0;
785783
Fpos = 0;
786784
return false;
787785
} // endif use

0 commit comments

Comments
 (0)