public class UpdateBrandBatch implements Database.Batchable<sObject>, Database.Stateful {
final List<SObject> records = new List<sObject>();
final string query1, query2;
public updateBrandBatch(){
query1 = 'select id, brand__c from account';
query2 = 'select id, brand__c from contact';
}
public Iterable<sObject> start(Database.BatchableContext BC) {
records.addAll(Database.query(query1));
records.addAll(Database.query(query2));
return records;
}
public void execute(Database.BatchableContext BC, List<sObject> scope) {
for (sObject c : scope) {
c.put('brand__c', 'MyBrand');
}
update scope;
}
public void finish(Database.BatchableContext BC) { }
}
Calling this batch from anonymous window using :
Database.executeBatch(new UpdateBrandBatch(), 20);
even though i enter batch size as 20, still getting the exception. There are some 20 million records of account and about 30 million contacts
Thanks
went through question # 60164 here in SOF and as per suggestion tried reducing the batch size but that didnt help.