How do I check if an sqlite query returned anything before I stop looping through results.
//see if there are results and do something if not
while(sqlite3_step(selectstmt) == SQLITE_ROW)
{ /*process on reults */}
How do I check if an sqlite query returned anything before I stop looping through results.
//see if there are results and do something if not
while(sqlite3_step(selectstmt) == SQLITE_ROW)
{ /*process on reults */}
I think I'm missing something in your question, if it returns SQLITE_ROW then it has a row ready for reading.
The API is at http://www.sqlite.org/capi3ref.html#sqlite3_step
You can access that data through the column functions:
http://www.sqlite.org/capi3ref.html#sqlite3_column_blob
So you're basically doing the correct thing, while sqlite3_step return SQLITE_ROW you still have data to access.
// Clarification
SQLite fetches and gives you the rows one at a time by using sqlite3_step, calling it won't retrieve the whole resultset. So you won't know until you call step whether you're going to get data.
I've had to use SQLite quite a bit when I worked on embedded devices, but always through a decent DAL. I'm not a huge fan of it's API, but it is lightweight I guess.