is wxSQLite3 Resultsetquestion Topic is solved

In this forum you can discuss database related issues which can be wxWidgets related, but also generic in nature.
Post Reply
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

is wxSQLite3 Resultsetquestion

Post by evstevemd »

Hi,
I need to compare two resultsets and they are having different rows. So I wanted to know what happens if I call NextRow() after last row? Does it crash or do something?
Thanks
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: is wxSQLite3 Resultsetquestion

Post by utelle »

evstevemd wrote:I need to compare two resultsets and they are having different rows. So I wanted to know what happens if I call NextRow() after last row? Does it crash or do something?
Currently this should not be done according to the SQLite documentation. But it would need only a minor modification to the NextRow method to make it safe: After reaching the last row of a result set the internal member variable m_eof is set. On further calls this variable could be checked and NextRow could return false immediately without calling any SQLite functions.

Regards,

Ulrich
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: is wxSQLite3 Resultsetquestion

Post by evstevemd »

utelle wrote:
evstevemd wrote:I need to compare two resultsets and they are having different rows. So I wanted to know what happens if I call NextRow() after last row? Does it crash or do something?
Currently this should not be done according to the SQLite documentation. But it would need only a minor modification to the NextRow method to make it safe: After reaching the last row of a result set the internal member variable m_eof is set. On further calls this variable could be checked and NextRow could return false immediately without calling any SQLite functions.

Regards,

Ulrich
So you mean that once eof is reached calling nextrow without doing anything else to resultset is safe and just returns false?

I want to be able to test if eof is reached in one rs so that I will not touch it and deal with the other one!
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: is wxSQLite3 Resultsetquestion

Post by utelle »

evstevemd wrote:
utelle wrote:
evstevemd wrote:I need to compare two resultsets and they are having different rows. So I wanted to know what happens if I call NextRow() after last row? Does it crash or do something?
Currently this should not be done according to the SQLite documentation. But it would need only a minor modification to the NextRow method to make it safe: After reaching the last row of a result set the internal member variable m_eof is set. On further calls this variable could be checked and NextRow could return false immediately without calling any SQLite functions.
So you mean that once eof is reached calling nextrow without doing anything else to resultset is safe and just returns false?

I want to be able to test if eof is reached in one rs so that I will not touch it and deal with the other one!
The class wxSQLite3ResultSet has method Eof() to check whether all rows of the result set had been processed or not.

If Eof() returns true then don't call NextRow() anymore.

BTW NextRow() also tells you when you have reached the end of the result set. As long as NextRow() returns true there are still rows to process. Don't call NextRow() again after it has returned false once.

Regards,

Ulrich
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Post by evstevemd »

thanks a lot!
Just curious question. If I call nextrow after eof is reached what happens? Throws exception? Crash or what?
Thanks again for your usual support!
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Post by utelle »

evstevemd wrote:Just curious question. If I call nextrow after eof is reached what happens? Throws exception? Crash or what?
No idea, I never tested. NextRow calls internally sqlite3_step and the SQLite documentation states "SQLITE_DONE means that the statement has finished executing successfully. sqlite3_step() should not be called again ... without first calling sqlite3_reset() to reset the virtual machine back to its initial state ...". So anything might happen.

Maybe I should make NextRow throw an exception if it is called again after Eof is reached.

Regards,

Ulrich
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Post by evstevemd »

utelle wrote:
evstevemd wrote:Just curious question. If I call nextrow after eof is reached what happens? Throws exception? Crash or what?
No idea, I never tested. NextRow calls internally sqlite3_step and the SQLite documentation states "SQLITE_DONE means that the statement has finished executing successfully. sqlite3_step() should not be called again ... without first calling sqlite3_reset() to reset the virtual machine back to its initial state ...". So anything might happen.

Maybe I should make NextRow throw an exception if it is called again after Eof is reached.

Regards,

Ulrich
Thanks, I think adding exception is better than "anything can happen" :wink:
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Post Reply