> It would appear the DELETE was successful, and the first INSERT was
> successful. But when the second INSERT failed (as it was intended to)..it
> did not ROLLBACK the database.

Even though the second INSERT fails, your script still calls COMMIT
on an open transaction in which the DELETE and first INSERT have
succeeded.

Typically an application would explicitly call ROLLBACK after a
statement failure if it didn't want the transaction to commit. The
following for example works the way you probably want it to.

        CREATE TABLE A(id INT PRIMARY KEY, val TEXT);

        INSERT INTO A VALUES(1, "hello");

        BEGIN;
             DELETE FROM A;
             INSERT INTO A VALUES(1, "goodbye");  
             INSERT INTO A VALUES(1, "world");  
        ROLLBACK;

        SELECT * FROM A;

It appears your expectation is that if a statement fails then the
transaction is invalid (thereby ignoring the COMMIT). SQLite treats
that situation differently.

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

Reply via email to