On 1 Jul 2013, at 4:13am, Igor Korot <ikoro...@gmail.com> wrote:

> Well I will use another statement variable as in the sample code.
> My questions was: if I call delete on the record that was just retrieved in
> another query will this delete affects it?

I can’t say a definite 'yes’ because it depends on all sorts of details like 
whether there is a spanning index.  But the canonical answer to your question 
is that you shouldn’t do that.  Generally speaking, unless you know intimate 
details of how SQLite works, treat a _prepare() as a lock on the file which 
isn’t unlocked until you do _reset() or _finalize().

If a query is still open (i.e. you didn’t run _reset() or _finalize() on it) 
and you mess with a table that query consults, the results are not predictable.

For instance, suppose your query is

SELECT hometeam,awayteam FROM matches WHERE homescore = awayscore

and you did

DELETE matches WHERE rowid=163

there can be all sorts of problems if the SELECT statement is still pointing at 
row 163 when you delete it.  It might not know how to get from a non-existant 
row to the next valid row, for instance.

Basically, no, don’t do that.  It’s safe to mess with /another/ table, one 
which isn’t mentioned in your SELECT.  But to mess with the table you’re 
looking at make a list of rows to delete and delete them when your SELECT is 
finished.  Or write a WHERE clause for your DELETE that figures out which rows 
to delete for you.

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

Reply via email to