[Gambas-devel] gb.odbc probably won't work correctly

danielcampos at ...45... danielcampos at ...45...
Thu Oct 13 21:24:02 CEST 2005

(Gambas-1.9.20 / gb.db / gb.db.odbc / Informix)


I've been testing gb.db.odbc with Informix, and it does not work. The problem is that gb.db tries to get the row count of a "SELECT" query, and that value is not reported by the major part of ODBC drivers (well, MySQL does, but it has not very much sense having a native driver). For example you can look at the IB M documentation about ODBC:


...or the Perl-ODBC documentation (I have not the link now,sorry)

The major part of ODBC drivers report the row count only for INSERT, UPDATE or DELETE queries, and return -1 for SELECT queries, when using the SQLRowCount() method.

I've made a hack for me, that repeats twice the query, the first one to count the number or rows, and the second one to fill the data. It works OK, but I remember an old mail from Benoit saying that this is "horrible", however is the only thing I can do from the driver currently. It seems there's a commented code in the gb.db part about this, however it is disabled...

The second porblem is that "FetchScroll()" method does not work for Informix, and it seems it will not work for DB2, according to IBM documentation, that says nothing about that method, so, in my hack, I've replaced it by "Fetch()"...

Once I stabilize my hacks trying to make it work correctly, I will release it as an "odbc2" or something like that unnoficial driver, as I need these features for Informix, and may be It will help other developers. 

However, I think something more  clean should be done with that, may be a complete component for ODBC with a different interface, or modify the current gb.db component so it can handle drivers having not row counting and a forward-only cursor (I think MoveFirst, MovePrevious, etc won't work correctly with the current interface). It is important to support DB2 and Informix!


Daniel Campos

NetCourrier, votre bureau virtuel sur Internet : Mail, Agenda, Clubs, Toolbar...
Web/Wap : www.netcourrier.com
Téléphone/Fax : 08 92 69 00 21 (0,34 € TTC/min)
Minitel: 3615 NETCOURRIER (0,16 € TTC/min)

More information about the Devel mailing list