ApexSensei

All drills

Change records (DML): Apex practice drills

Insert, update, upsert and delete, Database methods, save results, savepoints and bulk-safe DML.

9 drills · Intermediate · Free to read, run with Apex Path ($19/month after a 7-day trial)

  1. SObject field access (Beginner, 8 min)
    Set and read Account fields with dot notation and dynamic SObject methods without saving a record.
  2. Insert a tagged Account (Beginner, 10 min)
    Insert one uniquely tagged Account and verify the saved record by its assigned Id.
  3. Update a tagged Account (Beginner, 12 min)
    Create one tagged Account, update its Description, and read the record before and after to prove the change.
  4. Delete challenge-created records (Intermediate, 12 min)
    Delete two tagged Accounts in one statement and prove they moved to the Recycle Bin.
  5. Bulk update once (Intermediate, 15 min)
    Prepare three tagged Accounts in a loop and update the collection with one DML statement.
  6. Upsert: insert or update (Intermediate, 15 min)
    Upsert one Account twice with Database.upsert and use isCreated() to show the first call inserts and the second updates.
  7. Handle Database.SaveResult (Intermediate, 15 min)
    Let one valid insert succeed while you read the status code of one invalid Account.
  8. Savepoint and rollback (Intermediate, 15 min)
    Insert a tagged Account after a savepoint, roll back, and show the row is gone while the Id stays on the variable.
  9. Insert an Account with Contacts (Intermediate, 18 min)
    Insert a parent Account, then its three Contacts in one list with AccountId set, and prove the link with a query.

Start practicing free