Is there a way to rollback a Delete Query in Outsystems?
Question

Hello all,

I had this question for a while. I wanted to know if there is a way to rollback a delete statement. For exemple, lets imagine that i delete some data by accident, is there a way to recover it?

If soo, how is it done?

Best regards!


If you had already publish the module with the query in place, just use the option "Compare and merge with another version or file", 

-   choose the version with the query

- Find the query in the right of the popup

- Copy ( select and Ctrl C) the query 

Close the opup

And beck in the in your action Paste the query. 

Regards , hope this helps

Graça

  

Hi Graça,


i don't think that you have understood my question. Let me try to explain a bit more:

Imagine that i have a action that contains a Sql Query that selects the data. Then, uses a for Loop to iterate throught the selected data and applies the Delete Action to delete it.

Is there a way to recover thee deleted data after executing the action?

I did try your suggestion but it didn't work.


Best Regards!


Hi Luís,

If you have any database backup plan then you can restore database from backup plan. 

Thanks

Vinod

mvp_badge
MVP

When you restore an OutSystems database, you are not restoring a transaction but rollback to state of one day before, and not only on data but also on the meta data (the application logic).

Hello Luis, 

No, once you use a instruction to the data base (Delete Action is an instruction to the data base ) and the action ends it's final. 

You may create an exception and in the Exception Handler for that exception set the property "Abort transaction" to "Yes".  If the exception rises the systems rolls back all the work done during that action. 

Hope this helps. 

Graça

Hi Luís Amaro,

If your action has been executed without an error it means the transaction has been committed implicitly and you can not rollback the delete statement, in this case you need to look for restore database from backup plan as suggested by Vinod. (Although I do not have much idea on that)

But if your action is not completed and you want to put some logic for Rollback as suggested by Maria, You may create an exception and in the Exception Handler for that exception set the property "Abort transaction" to "Yes". The other way of doing this to use AbortTransaction action available in (System) dependency which issue a database ROLLBACK command that undoes all changes performed on the database since the last commit.  If AbortTransaction will better option so you have more control over the logic.

Hope this helps.

Pankaj

Hi Luís Amaro

In this case, you can't do anything until you have some database backup with you.


Thanks

Ankit S

mvp_badge
MVP

Several ways of mitigating this situation, are to use an IsActive attribute on your entity and do a "soft-delete" by setting records inactive. You would still need more a transaction number attribute on the entity, or something if you want to automate the rollback. But with the IsActive attribute at least you would be able to "recover" the soft-delete.

Alternatively you could before the bulk delete export the to be deleted data to excel, and create an import from excel function.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.