Batch Apex
As its name suggests, batch Apex is used to invoke and process a potentially large number of records in batches, where the number of records is determined by issuing a query to Salesforce. This execution typically lends itself well to situations where a potentially large number of records could need processing, yet the exact number of records isn’t known, such as updating records as part of an overnight batch procedure.
batch Apex classes must implement the Database.Batchable
interface and therefore the start
, execute
, and finish
methods. A bare-bones Apex class for implementing the Database.Batchable
interface would look similar to the following:
public class myBatchClass implements Database.Batchable {
public Database.QueryLocator start(Database.BatchableContext info){}
public void execute(Database.BatchableContext info, List<sObject> scope){}
public void finish(Database.BatchableContext...