kwood-pluscon
6/6/2019 - 5:05 PM

Apex Batch Class Base

Apex Batch Class Base

global class BatchExample implements Database.Batchable<sObject>, Database.Stateful {
	
	// instance member to retain state across transactions
	global Integer recordsProcessed = 0;

	global Database.QueryLocator start(Database.BatchableContext bc) {
		return Database.getQueryLocator(
			'query'
		);
	}

	global void execute(Database.BatchableContext bc, List<Account> scope){
		// process each batch of records
		
	}

	global void finish(Database.BatchableContext bc){
		System.debug(recordsProcessed + ' records processed!');
		
	}
}