Why can't the knowledge of the "last row" be obtained and used by the application after _step returns SQLITE_DONE?
Although what Doug suggested could work, it doesn't make sense to me to add an extra count or max query just to know how many results will be returned when those results will be queried anyway. On Tue, Oct 15, 2019, 1:16 PM Doug <dougf....@comcast.net> wrote: > How about something like this that costs more to run: > > Given a table T with columns A, B, C,.. > BEGIN TRANSACTION > SELECT Count(*) AS Count [filter spec]; > SELECT A,B,C,... [filter spec]; > ROLLBACK or COMMIT > > Doug > > > -----Original Message----- > > From: sqlite-users <sqlite-users-boun...@mailinglists.sqlite.org> > > On Behalf Of Simon Slavin > > Sent: Tuesday, October 15, 2019 8:35 AM > > To: SQLite mailing list <sqlite-users@mailinglists.sqlite.org> > > Subject: Re: [sqlite] Last record > > > > On 15 Oct 2019, at 4:34pm, Philippe RIO <51...@protonmail.ch> > > wrote: > > > > > how could I know if I am reading the last record with > > > sqlite (sqlite3_step)? > > > > Sorry, there's no way to do that for some arbitrary SELECT. > > Because SQLite itself may not know. > > > > SQLite does not always process your query and store all the > > results in memory. If there's an ideal index for your query, each > > call to _step() just one more row. SQLite itself doesn't know it > > has reached the end until it gets an error because it runs off the > > end of the index. > > _______________________________________________ > > sqlite-users mailing list > > sqlite-users@mailinglists.sqlite.org > > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite- > > users > > _______________________________________________ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users