[Gambas-devel] ODBC - new version

Benoit Minisini gambas at ...1...
Thu Apr 14 17:43:00 CEST 2005


On Thursday 14 April 2005 11:52, Andrea Bortolan wrote:
> Hi Benoìt,
> here the last version of the ODBC module, this should
> be a "beta" version...all the function that odbc
> provides are implemented.
> In order to test the ODBC connection I made some
> changes in the  Gambas database manager and in the
> Database example,in attach you'll the modified files.
> I made only "little" changes to avoid errors when try
> to manage database users (this function  is not
> implemented in ODBC standard) 

Good idea.

> and to manage the ODBC 
> standard behavior that returns -1 instead of the
> resultset rows number (mysql, postgresql and probably
> others DB return the correct number of rows, iSeries
> ODBC driver does not). You can find the changes
> easilly searching for "ODBC Changes" comment line.
> I added a function that fetch the rows till the ODBC
> rise the End of Data error, then return the rows
> conted,this function is named rowcount.
> I know this is a bad implementation but I'm not able
> to   make it better. If you think that this can be
> usefull  probably you can suggest me a better way to
> do that.
>
> Have a nice day, Andrea.
>
>

Thanks Andrea.

A few remarks:

1) You can choose, instead of returning an error, to implement what you added 
to the database manager directly in the driver. This way, some database 
manager hacks become unnecessary :-)

I mean, for example:

table_is_system() will always return that the table is not a table system, 
instead of returning an error.

user_*() functions will always behave as if there is only one user, the login 
passed to the Connection object.

2) Never use printf() or fprintf(stderr...). Or put the messages between 
#ifdef/#endif so that they can be disabled.

3) When there is an error:
a) Call GB.Error() with the true error message. Don't put "ODBC Error". Put 
the error message.
b) Return immediately. GB.Error() does not return from the function from you. 
This function just record the error message for displaying it later.

Regards,

-- 
Benoit Minisini
mailto:gambas at ...1...




More information about the Devel mailing list