Look, Sir, I appreciate that you have spend your time and energy responding
to my question, in fact, I have used your suggestion to have a look at the
other guys' C++ wrappers of the SQLite3 library, but my intention is to
learn SQL using the SQLite3 API. I am using C++ and not the 'prompt',
because I will ultimately use C++ to implement my knowledge of SQL and
SQLite3.
Just so that we are clear, I don't mind trying and failing a thousand times,
I need to know how this thing works!
On the other hand, I really like your analogy of the book being opened, the
pages being read and then closing the book again, it is brilliant concept. I
see now that I need to reorganize my class so that I can have the
'finalizer' method called only once at the end of the database transaction.
I hope, and I am counting on everyone here, to eventually release mySQLite3
in the public domain.
Again, thanks so much for your help and have a wonderful day.


-----Original Message-----
From: sqlite-users-boun...@sqlite.org
[mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Igor Tandetnik
Sent: Tuesday, September 11, 2012 11:24 PM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] C++ - HOW MANY rows?

Arbol One <arbol...@gmail.com> wrote:
> Since the call to the sqlite3_step function is inside the 
> mySQLite3::read_* class-function/method

... it is clear that you have a poor class design. As you would generally
want to read several columns from the same row, it is unwise to have a
read_* method call sqlite3_step, thus advancing to the next row. It is even
less wise to have it call sqlite3_prepare and sqlite3_finalize.

> Now, in a while loop inside
> Runner::read_tblName() I could call the mySQLite3::read_* for the data 
> to be retrieved, but instead of reading the next row of data, it keeps 
> on reading the same row again and again.

Because you prepare and finalize the stament again and again. Think about it
this way: sqlite3_prepare call opens a book, sqlite3_step call turns a page,
sqlite3_finalize call closes the book shut. Your read_* method opens the
book, turns to the first page, reads one line, then closes the book. The
next read_* call opens the book again, turns to the first page again, reads
another line, and closes the book. Again, and again.

Is it still surprising that you never progress past the first page?

> Obviously my problem is in design

Indeed.

> but I don't have enough experience using SQLite3 to come up with a better
idea.

In this case, perhaps you should consider using, or at least studying, some
existing libraries. There's no shortage of them:

http://www.sqlite.org/cvstrac/wiki?p=SqliteWrappers

--
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to