mardi 5 janvier 2016

Rollback SQLite transaction operations in case of failure

How can I rewrite my transaction to undo changes since the beginning whenever an error condition occurs before the end?

I see this question has already been asked and I followed the link provided in that answer. It's not clear to me what the next step is. I am hoping someone can illustrate the solution with an example applied to this transaction:

BEGIN TRANSACTION;
INSERT INTO Employee(ID, Name) VALUES(1, 'John');
...
<some failure happens here>
...
END TRANSACTION;

In this case, I would like the insert into the Employee table to be undone because a failure occurs before END TRANSACTION. How do I write rules that enforce this? This is for sqlite version 3.9.2.

Aucun commentaire:

Enregistrer un commentaire