On Sun, 24 Jul 2005, Kim Bendtsen wrote: >Hi There > >After executing a query I get the result back and can traverse it using >sqlite3_step. This is fine for most systems, however for what I wish to use >SQLite for, I would need something similar to stepForward, stepBackward, >stepToFirst, stepToLast. > >The application where I'm going to use it is when showing a list items from a >database table in a window. If the window can display 5 items, there is no >need to load more than 5 rows in the beginning. Here sqlite3_step is >sufficient. But >if the users press up arrow, it should take them to the bottom of the list, >and I would like to use something similar to setToLast. If the user keep >pressing up, I would need to stepBackward. >I know this might not be something for the sqlite database. How would you go >about wrapping this interface? I know it is a broad question and your >suggestion is very much appriciated! :)
You can build the result set into an array, then step through, back and around the array. SQLite already provides this functionality: http://www.sqlite.org/capi3ref.html#sqlite3_get_table The only downside is that you'll have the full result set in memory, even if you are only using a small portion of it. If you want to limit the amount of data at any time, you can use the: SELECT ... LIMIT n OFFSET m; form of select, where n is the number of rows you want, and m is the offset you want to start from. For a table view, this may be appropriate, but you have to recompute the results for each change of page, potentially slowing your app down for large queries. > > >Cheers >Kim B. > Christian -- /"\ \ / ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL X - AGAINST MS ATTACHMENTS / \