Is it possible to re-use the sqlite3 output?I have query like this :
error = sqlite3_prepare_v2(conn,SQL_STMT_GET_FILE,-1, &res, &tail);
error = sqlite3_bind_text(res, 1,file,strlen(file), SQLITE_STATIC); assert(error == SQLITE_OK);
if (error != SQLITE_OK) {
handle_error("No matching record found.");
and results are parsed
while (sqlite3_step(res) == SQLITE_ROW)
//do something here with results for device X
Now I would like to re-use the output ‘res’ for example, the code flow will be like
while (sqlite3_step(res) == SQLITE_ROW)
//do something here with results for device X
//reset the cursor to starting position and scan through the records.
while (sqlite3_step(res) == SQLITE_ROW)
//do something here with results for device Y
How to achieve this ? I prefer not to re-run the same sql statement for the second time and fetch the results.
You must either cache the data yourself, or re-run the query.
Read about the reasons on this page about Sqlite and Scrolling Cursors, including: