Clay Dowling wrote:
Andrew,

What you're trying to do won't work.


Clay is correct. The btree code in SQLite will get confused if you delete (or otherwise modify) entries in a table while SQLite is trying to scan that table. This means that you cannot do a DELETE on the table in the middle of a SELECT on the same table. This, in turn, means that you cannot do cursor-like things in SQLite.

One work around is to load the results of your SELECT into
a TEMP table, then loop through the TEMP table to do your
DELETEs.  SQLite does allow you to delete, update, or insert
tables from within the middle of a select as long as the
tables being updated, deleted, or inserted are distinct from
those being queried.

There is currently some discussion of enhancing the btree
layer so that it can support a DELETE on a table that is
simultaneously being queried (provided that both happen
in the same database connection - this is not a form of
concurrency.)  This can get very tricky, though, if the
SELECT is really a join.  If an when such changes are made,
Andrew's code should start working.

--
D. Richard Hipp -- [EMAIL PROTECTED] -- 704.948.4565



Reply via email to