1
2List<Account> accList = new List<Account>{new Account(Name='Myacc1'),new Account(Name='MyAcc2')};
3insert accList;
4
5Account masterAcct = [SELECT Id, Name FROM Account WHERE Name = 'Myacc1' LIMIT 1];
6Account mergeAcct = [SELECT Id, Name FROM Account WHERE Name = 'MyAcc2' LIMIT 1];
7
8try {
9 merge masterAcct mergeAcct;
10} catch (DmlException e) {
11 // handle the exception
12}
13
14