04 · DML and the database
Article lesson
20m
1 min read
insert, update, upsert, delete — and what happens to the transaction when one record out of two hundred fails.
All or nothing, unless you ask
Plain DML rolls the whole batch back on one failure; Database.insert(records, false) lets the rest through and hands you the errors. Know which one each situation needs.
Upsert and external IDs
Upsert against an external ID field is the backbone of every integration you will ever build. We set one up and watch it match.
Practice in your org
- Open your Developer Edition org and follow along step by step
- Change one thing at a time and note what happens
- When something breaks, read the error before searching for it