[Gambas-user] Issue 192 in gambas: SQLite3 Exec of a 'Select' statement returns too many rows

gambas at ...2524... gambas at ...2524...
Thu Jan 12 11:55:21 CET 2012


Status: New
Owner: ----
Labels: Version Type-Bug Priority-Medium OpSys-Any Dist-Any Arch-Any  
Desktop-Any GUI-Any

New issue 192 by john.aar... at ...626...: SQLite3 Exec of a 'Select'  
statement returns too many rows
http://code.google.com/p/gambas/issues/detail?id=192

Problem with Result object in that SQLite3 Exec of a 'Select' statement  
returns too many rows.

Version: TRUNK or BRANCHES/2.0 or 2.22.0
Revision: r1234 (if you use a development version)
Operating system: Linux
Distribution: Ubuntu 10.04
Architecture: x86
GUI component: GTK+ (i.e. default)
Desktop used: Gnome

I'm using Ubuntu 10.04 which uses SQLite3 version 3.6.22. I'm using Gambas  
2.22.

I've created a database one of whose tables is called country with  
definition of:
Create Table country (_id Integer Primary Key AutoIncrement,
                                country Text Not Null);

When I run code:

PUBLIC ResultCountry AS Result

PUBLIC SUB SelectCountry()
   DIM query AS String
   query = "Select * From country"
   ResultCountry = DatabaseConnection.Exec(query)
   PRINT "Count = " & ResultCountry.Count
   FOR EACH ResultCountry
     PRINT ResultCountry!_id, ResultCountry!country
   NEXT
CATCH
   Error.Raise("Select database country table records error</b><hr> Error: "  
& DConv(Error.Text))
END

I get in Console:
Count = 2
1       France
2       Great Britain
4
5
6France
5
6Great Britain

The above looks contradictory in that it shows a count of 2 rows  
but 'ResultCountry' contains 7 rows some of which have a duplicate primary  
key!

SQLite Manager & SQLite database browser both show that the table only  
contains 2 records i.e.:
1       France
2       Great Britain

I've even dropped & recreated the table but with the same result.

Project & database attached.

PS I found out about this because in subsequent code (which called the  
above SUB and used the resulting 'ResultCountry'), I had a runtime error  
of 'Not an object' and I started putting in print statements to find out  
the cause.


Attachments:
	JewishHeritage.tar.gz  8.2 KB
	JewishHeritage.db  8.0 KB





More information about the User mailing list