I have a list of master accounts that each map to a single duplicate account.
I want to merge each master with its corresponding duplicate using the merge
DML operation.
I'm currently doing this in a for loop:
for (Account master : listMasters) {
Account duplicate = mapMasterToDuplicate.get(master);
try {
merge master duplicate;
} catch (DmlException e) {
...
}
}
Is there a way to do this without executing DML in a loop?
I am implementing this in a batch class, and I am limiting the scope size when I execute the batch job, so I'm not too worried about exceeding governor limits. I just want to check if there's a more efficient method of accomplishing this batch merge that I couldn't find.