[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mysql-odbc
Subject:    RE: clipper+fivewin can access mysql but skip -1 bug
From:       Uwe Hein <uwe.hein () ob ! kamp ! net>
Date:       2001-09-20 8:40:52
[Download RAW message or body]

In article <9n9qgq$2e1r$1@FreeBSD.csie.NCTU.edu.tw>, Venu wrote:
> From: venu@mysql.com (Venu)
> Newsgroups: mailing.database.myodbc
> Subject: RE: clipper+fivewin can access mysql but skip -1 bug
> Date: 7 Sep 2001 14:46:50 +0800
> 
> Hi !!
> 
> )-----Original Message-----
> )From: Wang Shuming [mailto:wangshuming@xtech.com.cn]
> )Sent: Thursday, September 06, 2001 8:15 PM
> )To: myodbc@lists.mysql.com
> )Subject: clipper+fivewin can access mysql but skip -1 bug
> )
> )
> )Dear Sir:
> )   We use Clipper5.2+fivwin 2.1 through myodbc 2.5  can access mysql
> )3.23.38 but when locate on the first row of a table, execute skip -1
> )(xbase command or function ), it shows you are on the second row, that
> )says you execute skip 1 not skip -1.
> 

Hi,

   I had a similar problem. The reason is the fact, that MyODBC returns 
SQL_SUCCESS_WITH_INFO instead of SQL_NO_DATA when skipping beyond BOF -1
   
   Here is my workaround in VISUAL OBJECTS
   
   
********* Code starts here ***********************


Method Skip(nAmount as longint) as logic pascal class cmSQLSelect
//-----------------------------------------------------------------------------
//         Name : Skip()
//
//  Description : This method skips the record pointer by the specified number 
//                of rows.
//      This method is a workaround for a MySQL bug not returning the 
//       correct SQL_ERROR code when skipping beyond BOF of the result set
//
//       Remark : The ODBC driver must support extended fetches or this method 
//                                           will fail.
//   If nAmount > 1 or nAmount < -1 the driver must also support 
//                       SQL_FETCH_RELATIVE.
//-----------------------------------------------------------------------------

   local nNumRows    as longint
   local nRowStatus  as longint
   local nRetCode    as shortint

    // *-* Begin Fix for MySQL ODBC Bug *-*
   local nCurrentRow as longint
    // *-* End Fix for MySQL ODBC Bug *-*

   local oApp        as cm_App

   local symServer   as Symbol

~"ONLYEARLY+"

   oApp      := GetAppObject()

   symServer := oApp:Shell:SQLConnection:symServer

   self:lBOF := false
   self:lEOF := false

   if nAmount == 1

      nRetCode := SQLExtendedFetch(self:oStatement:HStatement, SQL_FETCH_NEXT, 
0, @nNumRows, @nRowStatus)

   elseif nAmount == -1

      nRetCode := SQLExtendedFetch(self:oStatement:HStatement, SQL_FETCH_PRIOR, 
0, @nNumRows, @nRowStatus)

    if symServer = #MYSQL

       // *-* Begin Fix for MySQL ODBC Bug *-*
          // you need this to get the row position by nCorrentRow
         SQLSuccess(SQLGetStmtOption(self:oStatement:HStatement, 
SQL_ROW_NUMBER, @nCurrentRow))
       // *-* End Fix for MySQL ODBC Bug *-*

    endif symServer = #MYSQL

   else

      nRetCode := SQLExtendedFetch(self:oStatement:HStatement, 
SQL_FETCH_RELATIVE, ;
                                           nAmount, @nNumRows, @nRowStatus)
   endif

   if symServer = #MYSQL

       // *-* Begin Fix for MySQL ODBC Bug *-*
      if nCurrentRow = 1 .and. nRetCode = 1
         nRetCode := SQL_NO_DATA
      endif
       // *-* End Fix for MySQL ODBC Bug *-*

   endif symServer = #MYSQL

   if SQLSuccess(nRetCode)
      self:_FetchData()
      return true
   endif

   self:lBOF := nAmount < 0
   self:lEOF := nAmount > 0

   return false

~"ONLYEARLY-"

************** Code ends here ******************

   HTH
   
     Uwe
    

Uwe Hein  Folkwang Musikschule der Stadt Essen / Germany   
   Voca Ruhrpott  ---------   Thu, 20 Sep 2001 10:17 +0200
      Email: uwe.hein@ob.kamp.net




---------------------------------------------------------------------
Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
posting. To request this thread, e-mail myodbc-thread3891@lists.mysql.com

To unsubscribe, send a message to the address shown in the
List-Unsubscribe header of this message. If you cannot see it,
e-mail myodbc-unsubscribe@lists.mysql.com instead.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic