Transaction control
Each DML operation is a transaction. Like a record, which has a previous and a next version (you will learn about that during the explanation of triggers later on), a database operation also has a previous version (called a savepoint) and a next version (the version after the insertion of records).
When you need to insert two types of records, such as a list of accounts and contacts, you want to know whether your account is correctly inserted before you insert the contacts. Because DML statements only support only one type of object in one transaction, we need to perform two DML statements: one for the account, and a second statement for the contacts.
However, what if you entered an account, and one of the contacts failed ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access