In your application you can create a wrapping iterator that pre-reads
the next value instead or directly accessing the low level step
function.  Then you can ask if it is the last.

On 10/15/2019 9:44 AM, Simon Slavin wrote:
> On 15 Oct 2019, at 5:38pm, Philippe RIO <51...@protonmail.ch> wrote:
>
>> The only way is to make a query for getting the number of records and in the 
>> second query I have to count the number of records retrieved to know if it 
>> is the last one.
> Assume your intended query specifies an order which has unique keys (in other 
> words, you know exactly what order rows will be answered in.  Suppose it is
>
>     SELECT ... ORDER BY a, b DESC, c
>
> You can find the last row which will be returned by reversing the order and 
> adding LIMIT 1
>
>     SELECT ... ORDER BY a DESC, b ASC, c DESC LIMIT 1
>
> You can then remember the value(s) of some column(s) of the row returned, and 
> watch for the same one(s) when you do your desired SELECT.
>
> Depending on the number of rows in your result set, this may or may not be 
> faster than counting the number of rows.
> _______________________________________________
> 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

Reply via email to