On 10/5/2011 1:40 PM, Pero Mirko wrote:
So in other words a pseudo function like this:

BEGIN EXCLUSIVE
if anyerror return
INSERT INTO [table]
if anyerror ROLLBACK
INSERT INTO [table]
if anyerror ROLLBACK
UPDATE [table]
if anyerror ROLLBACK
UPDATE [table]
if anyerror ROLLBACK
COMMIT
if anyerror ROLLBACK
return

Would that guarantee ROLLBACK on any error?

Looks good to me.

Does last ROLLBACK knows it should rollback from BEGIN EXCLUSIVE or should I
still mark it with SAVEPOINT?

No, you don't need any SAVEPOINT.

The following was what I did with my tests
1. if i did say 10 "INSERT INTO" - and it failed at #7 - first 6 were kept,
7 was deleted
2. if i did the same but with INSERT OR ROLLBACK INTO... the same as 1.

Without an explicit BEGIN, every statement is executed in its own implicit transaction. As soon as the statement finishes successfully, that transaction is automatically committed. Fruther, since there's only one statement in the transation, there's no difference in behavior between the default ABORT clause and ROLLBACK clause.
--
Igor Tandetnik

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

Reply via email to