Salesforce Savepoints

Transaction control is an important part of any system that interacts with a database and Salesforce has neat ways of implementing said control.

Anyone that’s worked with SQL databases will be familiar with savepoints and rolling back, and Salesforce has implemented similar constructs. For those who haven’t heard of these terms wikipedia describes them as

savepoint is a way of implementing subtransactions (also known as nested transactions) within a relational database management system by indicating a point within a transaction that can be “rolled back to” without affecting any work done in the transaction before the savepoint was created.

rollback is an operation which returns the database to some previous state.

As with most things, the importance of these two features is best demonstrated using examples.

Read more