It looks like result::get_row_count() always returns zero after running a query. For example:
sqlite::query q(conn_, "SELECT key, size FROM cache ORDER BY access_time ASC;");
auto r = q.emit_result();
cerr << "row_count: " << r->get_row_count() << endl;
This prints 0 for a table with three records.
The problem I have is that I want to iterate over the results to do things with each record. But I can't. The approach in the example does not work:
do
{
cerr << "key: " << y->get_string(0) << endl;
} while (y->next_row());
The problem here is that the result set may be empty, in which case I don't want to do anything. But I cannot write a pre-tested loop without get_row_count(). The do loop will execute at least once, even if there are no results.
If I do run the above loop on an empty result set, I get
key: NULL
That's despite the fact that the corresponding table column is defined as NOT NULL.
What's the suggested way to process results row by row and doing nothing if there are no results?