What is the purpose of savepoint?

What is the purpose of savepoint?

A savepoint is a marker that defines the beginning of a nested transaction. This marker can be later used to commit or roll back just the effects of the nested transaction without affecting the progress of the enclosing transaction.

What is the use of savepoint in Salesforce?

setSavepoint in Salesforce? Database. setSavepoint() is used to define a point at which DML operations can be rolled back. If any error occurs during DML Operations, that contains many statements, the application will be rolled back to the most recent save point and the entire transaction will not be aborted.

What is database savepoint in Salesforce?

database. savepoint is a method which is used to define a point which can be roll back to. If any error occurs during a transaction, that contains many statements, the application will roll back to the most recent savepoint and the entire transaction will not be aborted.

When to use the savepoint command in SQL?

SAVEPOINT command is used to temporarily save a transaction so that you can rollback to that point whenever required. In short, using this command we can name the different states of our data in any table and then rollback to that state using the ROLLBACK command whenever required. Lets use some SQL queries on the above table and see the results.

What happens when you roll back to a savepoint in SQL?

A simple rollback or commit erases all savepoints. When you roll back to a savepoint, any savepoints marked after that savepoint are erased. The savepoint to which you roll back remains. You can reuse savepoint names within a transaction. The savepoint moves from its old position to the current point in the transaction.

How are commit, rollback and savepoint commands used?

Commit, Rollback and Savepoint SQL commands. Transaction Control Language(TCL) commands are used to manage transactions in the database. These are used to manage the changes made to the data in a table by DML statements. It also allows statements to be grouped together into logical transactions.

When to use save point and rollback in Salesforce?

Suppose you have written long code which contains many more DML statement, at the some point you will want this DML statement should not be executed, you may need to modify your code, at that time you will have to return that point, savepoint will identifies that point , Rollback will restore the database to that point (savepoint).