Hi List,
If I use sqlite3_exec to query a database,
How can I know that the results in the data base got over. For example If
I am expecting a 10 results in some for loop and actually there are only
five results , How can I get a notification or return value that the
results completed or Is there any way I can get SQLITE_DONE through
sqlite3_Exec. What return value I will get If I query an empty table.
Thanks and Regards,
Vivek R
SQLite didn't provide a "get number of rows" function for the result set. It
is mentioned in the document that sqlite3_exec is actually a wrapper for
sqlite3_prepare and sqlite3_step. It is in my opinion that sqlite3_exec
should only be used when the result of the query isn't that important. For
instance, a pragma query. For the record, sqlite3_exec did provide a
callback function in which you can count and get the number of rows in a
resultset. The optimal way is that you prepare the statement, fetch and
count the results with sqlite3_step.
Another thing I noticed from your question is that you might not want to
"expect 10 results". It's not very wise to design a hard loop such as
for(i=0;i<10;i++) when comes to a database query resultset. A better way
would be to use an array to store the result set they way you could
understand, and process them later. Then you'll have
for(i=0;i<array.size()<10?array.size():10;i++).
Best regards,
He Shiming
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------