[v.5.3, C# Selfservicing] Rollback after Commit

Posts   
 
    
Valemus avatar
Valemus
User
Posts: 37
Joined: 09-Jan-2018
# Posted on: 22-Feb-2018 10:10:28   

Hi,

I'm implementing an "undo" button, which should allow to rollback the last operation committed to the database.

I've seen that the Transaction is reset after the Commit, so I can't just save somewhere that Transaction and use it to Rollback later, correct?

Is there any best practice or suggestion to accomplish this kind of "undo"?

Thanks!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 22-Feb-2018 10:54:58   

You can 'save' a transaction (not on ms access), using a transaction savepoint. https://www.llblgen.com/Documentation/5.3/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/SelfServicing/gencode_transactions.htm#transaction-savepoints and either rollback that or commit it later.

Though it's not good for your case, as it keeps a transaction open and thus the locks on the rows. That means any select on the rows will block till you commit the transaction.

Undo in this case is really undoing the changes you've committed to the database, which can mean a lot, also entity references etc. so it depends on what your GUI is offering: in general these things are handled on the client till the user commits the work, which is then send to the DB and is thus final. The user can't undo past 'commit', and has to undo the work manually, OR you have to track what changes are made and then undo them manually through code, but that's not that simple.

Frans Bouma | Lead developer LLBLGen Pro
Valemus avatar
Valemus
User
Posts: 37
Joined: 09-Jan-2018
# Posted on: 22-Feb-2018 11:05:28   

Yes, I was hoping for some already existing trick, but I understand that is something very difficult to generalize.

Thanks!