[Gambas-devel] Change to gb.db.odbc to use ODBC Connection Strings.

Benoît Minisini gambas at ...1...
Wed Sep 16 02:24:27 CEST 2015


Le 14/09/2015 17:41, ML a écrit :
> Benoît,
>
> Continuing here as you requested.
> I found the problem in th driver that causes it to return 0 instead of
> -1 in the RowCount. The offending line and my patch:
>
>    //20150914 - zxMarce: Do NOT mark the STMT as Scrollable; it makes
> SQLRowCount always return 0 rows instead of -1.
>    //retcode = SQLSetStmtAttr(odbcres->odbcStatHandle,
> SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_SCROLLABLE, 0);
>    retcode = SQLSetStmtAttr(odbcres->odbcStatHandle,
> SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_NONSCROLLABLE, 0);
>
> It just needed a constant change from SQL_SCROLLABLE to SQL_NONSCROLLABLE.
> Looks like the intention was to make a proper driver, with forward and
> back scroll, but for some reason it was not completed.
>
> Now the problem propagates to Result.MoveNext and Result.Available. They
> loop forever, even when there's no more data to fetch.
> I made a further change in query_fill (removed a GB.Error that raised
> 'ODBC_NO_MORE_DATA' and added a return TRUE), but that did not get
> .MoveNext or .Available fixed:
>
>    if((retcode2 == SQL_NO_DATA_FOUND) || (retcode2==SQL_NO_DATA))
>    {
>      //GB.Error("ODBC_END_OF_DATA!"); //20150914 - zxMarce: Removed so
> .MoveNext and .Available work?
>      return TRUE; //20150914 - zxMarce: Try to make .MoveNext fail when
> no more data
>    }
>
> I think when we (you?) fix these problems, we will finally have a
> working Gambas ODBC subsystem.
>
> Thanks,
>

gb.db.odbc tells Gambas if he has a function to seek through a record at 
line 564 (with the no_seek connection flag).

But having that function does not mean that for a specific ODBC driver, 
seeking is actually possible.

In the query_fill() function at line 1152 you will see what the driver does:

- If the seek function exist, then:
   - If the result has been marked scrollable successfully, then move to 
the specified position.
   - If the result is not scrollable, then move to the next record.
- Otherwise, if the seek function does not exist, then move to the next 
record. If moving to the next record was not requested ('next' 
argument), then return TRUE (meaning an error).

So, apparently, it's just Gambas that does not handle the no_seek 
connection flag at the moment.

And we should force the query count to be -1 when seeking is not 
possible, whatever the reason (no seek function, or unscrollable query 
result).

-- 
Benoît Minisini




More information about the Devel mailing list