google-code-export / gambas

Automatically exported from code.google.com/p/gambas
1 stars 0 forks source link

SQLite3 Exec of a 'Select' statement returns too many rows #192

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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. 

Original issue reported on code.google.com by john.aaron.rose@gmail.com on 12 Jan 2012 at 10:55

Attachments:

GoogleCodeExporter commented 9 years ago
I forgot to enter the Gambas version as 2.22 (i.e. I left in the information 
relating to the development version).

Original comment by john.aaron.rose@gmail.com on 12 Jan 2012 at 10:56

GoogleCodeExporter commented 9 years ago
Please ignore (& remove?) this issue. I must have been sleeping when I thought 
I'd found a bug. What appear to be extra rows in the database table are due to 
PRINT statements that I put in the code in order to debug the cause of a 
runtime window popping up which said 'Not an object'. PS is it possible to add 
more information to this popup window e.g. line of code or its number?

Original comment by john.aaron.rose@gmail.com on 13 Jan 2012 at 3:40

GoogleCodeExporter commented 9 years ago
Can you elaborate. If you have a runtime error message, you should have a class 
name and a line number with it!

Original comment by benoit.m...@gmail.com on 14 Jan 2012 at 6:23

GoogleCodeExporter commented 9 years ago
As I said in comment #2, please ignore & remove this issue. It was posted in 
error.

Original comment by john.aaron.rose@gmail.com on 14 Jan 2012 at 5:21