Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sqlite step back

I found that the common way for scrolling forward through a result set is using sqlite3_step():

while (sqlite3_step(statement) == SQLITE_ROW) {
    // do something with the row
}

Is there a way to scroll backwards the result set, like going one step back or accessing a previous row using its ROWID?

Somewhere I have read that you can retrieve each record of the result set by its ROWID, but I can't figure out how.

If there is no such way for retrieving arbitrary rows in the result set, I will like to know whether it would be a bad practice or just a technologic limitation the reason for it.

like image 782
hectr Avatar asked Mar 16 '26 21:03

hectr


1 Answers

So I was going through the functions in the sqlite3 framework since I couldn't find any documentation online and found this:

sqlite3_reset(statement)

I didn't test, but since it takes a sqlite3_stmt just like sqlite3_step() does I assume it rewinds the result set back to the beginning.

like image 185
mattacular Avatar answered Mar 19 '26 09:03

mattacular