On 21 Feb 2013, at 6:56pm, Peter Aronson <[email protected]> wrote: > Thanks! The possibility we were wondering about was having an integer > primary > key autoincrement column and just exiting the select loop when encountering a > id > greater than the max id at start time (I assume this approach would not be > safe > if the integer primary key column was not autoincrementing).
You are correct in all the above. Another way to do it would be to first do a search and find the highest rowid for your outer SELECT: select MAX(rowid) from base1 where c3 < 15 and c1 = 1 OR select rowid from base1 where c3 < 15 and c1 = 1 ORDER BY rowid DESC LIMIT 1 then to use this value to limit the outer SELECT. Another way would be to build up all your INSERT commands into a long text string rather than executing them in the middle of the outer SELECT. Once the outer SELECT is finished you can execute the entire string in one go with sqlite3_exec(). However, the real secret to understanding how SQLite will do this is to understand that although the SQLite API lets you split _prepare() and _step() and _finalize() into separate steps, the assumption is that you will do all these things one after another without interrupting them with any other sqlite3_ calls. Simon. _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

