http://gambaswiki.org/bugtracker/edit?object=BUG.1100&from=L21haW4-

Comment #4 by zxMarce:

Actually, per practically any available documentation you can check, ODBC 
doesn't return a row count for SELECT statements.
I'll refer you to MSDN, for example 
(https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/sqlrowcount-function),
 but you can also check IBM's docs, which say the exact same:

Quote:
  SQLRowCount Function

  Conformance
  Version Introduced: ODBC 1.0 Standards Compliance: ISO 92

  Summary
  SQLRowCount returns the number of rows affected by an UPDATE, INSERT, or 
DELETE statement;
  an SQL_ADD, SQL_UPDATE_BY_BOOKMARK, or SQL_DELETE_BY_BOOKMARK operation in 
SQLBulkOperations; 
  or an SQL_UPDATE or SQL_DELETE operation in SQLSetPos

So, unless some not-so-easy mechanism is implemented, no ODBC interface will 
return you a row count for SELECTs.
The problem implementing the mechanism is that not all queries return a Result, 
for example the USE <database> command in MSSQL.

A high level ODBC interface would have a ton of things to take into account 
just to check whether a row count is returnable, necessary or even factible.
Add to that difficulty the fact that ODBC is actually not a driver per-se, but 
a driver manager and the problem only gets worse, because not all drivers 
implement all calls.

In short: You must use Result.Available (boolean) to check whether there are 
rows or not, and Result.MoveNext to loop records when dealing with ODBC.
I did implement a kind of row count for SELECTs, but it works or not depending 
on the underlying database driver (the one managed by ODBC), so you cannot rely 
on it.

One last thing: You can use a Connection String to connect to a database, if 
you know how to create it with your database driver of choice. Fill the 
Connection.Host property with the connection string instead of flling it with 
the Host Name and you're set. I connected to MSSQL and MySQL just changing the 
Connection String.

Almost forget: Regarding PHP, Java, etc, if anyone can tell me what to look at 
to get the infamous row count they claim they get with ODBC SELECTs, I'll 
appreciate it. Maybe I can add it to Gambas' ODBC.

Regards,
zxMarce.

zxMarce changed the state of the bug to: NeedsInfo.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to