On 5 Oct 2011, at 5:42pm, Pero Mirko wrote:

> Furthermore doing something like:
> BEGIN EXCLUSIVE
> INSERT OR ROLLBACK INTO table
> INSERT OR ROLLBACK INTO table
> INSERT OR ROLLBACK INTO table
> COMMIT
> 
> also doesn't make sense - because if first insert is successful and second
> is not it would keep first? Or not as it is within BEGIN/COMMIT block?
> 
> In my tests it never did partial inserts in BEGIN/COMMIT block but the docs
> do specify to issue ROLLBACK on error.

There is a big structure problem with INSERT OR ROLLBACK, because ROLLBACK ends 
the transaction.  So if you use the above structure and a ROLLBACK happens, 
subsequent 'INSERT OR ROLLBACK' commands will be their own little transactions, 
and the COMMIT at the end will generate an error because there is no BEGIN.

I would suggest instead that you use just INSERT (which I believe is equivalent 
to INSERT OR ABORT but I might be wrong).  This will give you the behaviour 
you're probably expecting when you explicitly declare a transaction.

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

Reply via email to