is wxSQLite3 Resultsetquestion  [SOLVED]

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

is wxSQLite3 Resultsetquestion

Postby evstevemd » Fri Feb 11, 2011 9:19 pm

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?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

utelle
Moderator
Moderator
Posts: 806
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: is wxSQLite3 Resultsetquestion

Postby utelle » Fri Feb 11, 2011 10:36 pm

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: 2090
Joined: Wed Jan 28, 2009 11:57 am
Location: Dar es Salaam, United Republic of Tanzania
Contact:

Re: is wxSQLite3 Resultsetquestion

Postby evstevemd » Fri Feb 11, 2011 10:48 pm

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?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

utelle
Moderator
Moderator
Posts: 806
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: is wxSQLite3 Resultsetquestion  [SOLVED]

Postby utelle » Sat Feb 12, 2011 7:12 am

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: 2090
Joined: Wed Jan 28, 2009 11:57 am
Location: Dar es Salaam, United Republic of Tanzania
Contact:

Postby evstevemd » Sat Feb 12, 2011 7:24 pm

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?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

utelle
Moderator
Moderator
Posts: 806
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Postby utelle » Sat Feb 12, 2011 9:33 pm

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: 2090
Joined: Wed Jan 28, 2009 11:57 am
Location: Dar es Salaam, United Republic of Tanzania
Contact:

Postby evstevemd » Sun Feb 13, 2011 12:20 am

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?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]


Return to “Database Related”

Who is online

Users browsing this forum: No registered users and 2 guests