CodeFusionMobile
CodeFusionMobile

Reputation: 15100

Can I rollback a SQLite transaction after it has been committed?

Is there a way in SQLite to essentially undo the latest transaction after it has been committed?

I'd like to revert the database to the state before a transaction or savepoint. I've looked at the rollback command, but it looks like it is limited to rolling back a pending transaction.

Edit Could I create a savepoint named "Undo" and wait to release it before starting the next action, or rollback if I need to undo it?

Upvotes: 4

Views: 5054

Answers (3)

LucasBr
LucasBr

Reputation: 481

I'm not an SQLite expert, but as far as I've tried, it's only possible to make savepoints inside transactions, but not the opposite.

And AFAIK, reading the online documentation, savepoints and transactions are essencially the same, the difference is the transaction stack in which the savepoints are written. You could open a certain number of savepoints (remembering the stack ordering) and, after checking it'a OK, make a transaction commit. I don't know if this will help you.

Upvotes: 0

Aravind Yarram
Aravind Yarram

Reputation: 80176

I am not sure if you are using JDBC 3.0. If you are then it supports savepoints. http://www.ibm.com/developerworks/java/library/j-jdbcnew/

Upvotes: 2

Rawheiser
Rawheiser

Reputation: 1218

Other than doing an on-line backup prior to your transaction, I don't know that it supports a "time machine" to go backwards in time.

Can't you put some application logic in place to record enough to undo the applied operation in audit trail table(s)?

Upvotes: 1

Related Questions