I've got a prepared statement from a original query that may have been stepped 
x times to row X.
I want to implement the functions:
FindFirst - find the first row (between row 1 and the last available row 
inclusive) that satisifies a new query.
FindLast - find the last row (between row 1 and the last available row 
inclusive) that satisifies a new query.
FindNext - find the next row (between row X and the last available row 
inclusive) that satisfies a new query.
FindPrevious - find the last row (between row 1 and row X-1 inclusive) that 
satisfies a new query.

What I thought I would do is generate a temporary table based on the original 
select statement and then execute the new query combined with rowid constraints 
and LIMIT of 1 in order to generate the row for the Find statement.
The new query is defined by SELECT * FROM original_select_sql WHERE new_expr.
I would generate atemporary table with CREATE TEMP TABLE temp_xxx AS 
original_select_sql;
So, for FindFirst the resultant new query would be SELECT * from temp_xxx WHERE 
(new_expr) LIMIT 1;
For FindNext: SELECT * from temp_xxx WHERE (new_expr) AND rowid > X LIMIT 1;

Is this the bset approach?
And if so, can you suggest queries for FindLast and FindPrevious?
And, can I depend on SQLite to generate results in the same order as the 
original prepare/step sequence and the temp table generation, ie. is the temp 
table's rowid going to be consistent with the original step order?

Thanks for any insight?

Vance
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to