
Force.com Cookbook Sample Code
Chapter 4: Best Practices for Writing Apex - Avoiding Apex Governor Limits
To download all the code samples, access the Cookbook. -
This Apex trigger is part of an example that demonstrates several methods for avoiding execution governor limits, including:
insert(), update(), and delete() operate in bulk
Limits.getDMLRows() for error handling
trigger BESTMassUpdateContactsOnAccountAfter on Account (after update) {
List<Contact> contactsForUpdate = MassUpdateContactsHelper.getContactsForUpdate();
update contactsForUpdate;
}
Sample code provided by salesforce.com. All rights reserved.