Savepoint setSavepoint():

Returns a savepoint variable that can be stored as a local variable which we can use with a rollback method to restore the database to that point.

Void rollback(Savepoint sp):

Restores the database to the state specified by the savepoint argument. Any emails submitted since the last savepoint are also rollbacked and not sent.

Savepoint sp1 = new Database.setSavepoint();

List<Account> accList = [SELECT name, phone FROM account WHERE name like ‘Acc%’];

integer i = 1;

for(Account a: accList)

{ = i+’ ’;



update accList;

Savepoint sp2 = Database.setSavepoint();

for(Account b: accList)

{ + ’ss’;


Update accList;

Savepoint sp3 = Database.setSavepoint();



else if(roll=2)


else if(roll=3)


Our Recent Blog

Share This Post