Google News
logo
Salesforce - Interview Questions
What are the different methods of Batch Apex class?
Database.Batchable interface contains three methods that must be implemented :
 
Start method : We use the start method at the beginning of the batch apex job. We use it for collecting the objects or records, for passing them to the interface for executing. It returns a DatabaseQueryLocator object that comprises objects or the records sent to the job.
global (Database.QueryLocator | Iterable) start(Database.BatchableContext bc) {}
Execute method : We use this method for every batch of the records that are sent to the method. We use this method for data processing. This method does the following :
 * sObjects records list
* Reference to the DatabaseBatcheable context.
global void execute(Database.BatchableContext BC, list<P>){}
Finish method : We call this method once we finish the batch processing. We use this method to send confirmation emails or to execute the post-processing operations.
global void finish(Database.BatchableContext BC){}
Advertisement