i have scenario like in a single transaction i am doing 2 DML operation. First one is delete,second one is update. If i get any issue while update the record , the deleted record should be reverted back (should be undeleted)

1 Answer 1


Yes, it will work for the delete DML operation. From the documentation Transaction Control:

Only when all the Apex code has finished running and the Visualforce page has finished running, are the changes committed to the database. If the request does not complete successfully, all database changes are rolled back.

With regards to the Savepoint statement:

Any DML statement that occurs after the savepoint can be discarded, and the database can be restored to the same condition it was in at the time you generated the savepoint.

It means that delete operation will be rolled back. In your code you have to make sure you use Database.rollback(sp); statement to rollback to the previous state.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .