What DML operations are available in Apex and what does upsert do?
Suggested answer
DML operations: insert (creates new records), update (modifies existing records), upsert (inserts if no match found, updates if match found), delete (moves to Recycle Bin), undelete (restores from Recycle Bin), merge (merges up to 3 records of the same type, deleting duplicates). Upsert: Uses a specified external ID field (or the record Id) to determine if a record exists. If a match is found, the record is updated; otherwise it is inserted. Syntax: upsert records ExternalId__c; Use Database.upsert() with allOrNone=false for partial success. Upsert is ideal for data integration scenarios where you cannot guarantee whether a record already exists.
Practice content for interview preparation; not an official vendor answer. Verify details against current product documentation.
Community comments (0)
No comments yet.
Sign in or create a free account to add a comment. Comments are moderated before they appear.