[Gambas-user] prb:Connection.Exec() bypass sql code
Benoit Minisini
benoit.minisini at ...2...
Sat Apr 29 20:22:37 CEST 2006
On Saturday 29 April 2006 19:36, ron wrote:
> function GetRecordCount(mytable) as integer
> dim Count as integer
> dim sql as string
> dim hResult as result
>
> sql="select count(*) from " & mytable
> hresult = hConn.exec(sql)
> count = hResult.count
> hResult=null
> return Count
> end
>
> This returns for Count 1 and the table has 20000 records
> and each record contains at around 1000bytes (not realy)
>
> Using the Count(*), wich is valid SQL syntax as far i know,
> the backend returns to me 1 record with 1 field and the content
> of the field is the record count in the table.
>
> As I understood from help the hConn.exec passtrough the sql
> text as is.
> However it functions only with "select * from table" and would
> return 20000x1000 bytes as the request is now.
>
>
> Somehow this is not logic to me, using a sub routine to get the
> count this way may not logic for others but it is part of more.
> Just stripped to basics.
>
> using mysql from cli gives:
>
> mysql> use selectdemo;
> mysql> show tables;
> +----------------------+
>
> | Tables_in_selectdemo |
>
> +----------------------+
>
> | makes |
> | models |
> | options |
>
> +----------------------+
> 3 rows in set (0.00 sec)
> *** returns 1 field as "Tables_in_selectdemo" and 3 records
>
> mysql> select count(*) from makes;
> +----------+
>
> | count(*) |
>
> +----------+
>
> | 7 |
>
> +----------+
> 1 row in set (0.23 sec)
> *** returns 1 field as "count(*)" and 1 records
>
> mysql> select * from makes;
> +--------+-----------+
>
> | makeID | makeName |
>
> +--------+-----------+
>
> | 1 | Ford |
> | 2 | Pontiac |
> | 3 | Chevrolet |
> | 4 | Hyundai |
> | 5 | Porsche |
> | 6 | niels |
> | 7 | ernie |
>
> +--------+-----------+
> 7 rows in set (0.04 sec)
> *** returns 2 fields and 7 records
>
> Have a nice day,
>
> Ron
>
And what is the problem ?
--
Benoit Minisini
More information about the User
mailing list