You need to sign in to do that
Don't have an account?
Janna McNeil
Developer Script Exception - Too many query rows
I am working to troubleshoot a batch Apex job that runs on a schedule but returns errors. I've read that I need to batch some of the queries but I have no idea how to do that. The Apex Job runs a batch update of all of our accounts from a couple of different custom objects. Any assistance or a point in the right direction would be greatly appreciated since I inherited this code. Thank you.
global class BatchUpdateAccounts implements Database.Batchable<sObject>, Database.Stateful {
global final String query;
global final Date inputDate;
global Date maximumDate;
global BatchUpdateAccounts(String q, Date d){
query = q;
inputDate = d;
}
global Database.Querylocator start(Database.BatchableContext bc) {
try {
Date d = Date.today();
Date targetDate;
if(d.month() == 1 || d.month() == 2 || d.month() == 3) {
targetDate = Date.newInstance(d.year(), 1, 1);
}
else if(d.month() == 4 || d.month() == 5 || d.month() == 6) {
targetDate = Date.newInstance(d.year(), 4, 1);
}
else if(d.month() == 7 || d.month() == 8 || d.month() == 9) {
targetDate = Date.newInstance(d.year(), 7, 1);
}
else {
targetDate = Date.newInstance(d.year(), 10, 1);
}
Only a portion of the code is included here.
global class BatchUpdateAccounts implements Database.Batchable<sObject>, Database.Stateful {
global final String query;
global final Date inputDate;
global Date maximumDate;
global BatchUpdateAccounts(String q, Date d){
query = q;
inputDate = d;
}
global Database.Querylocator start(Database.BatchableContext bc) {
try {
Date d = Date.today();
Date targetDate;
if(d.month() == 1 || d.month() == 2 || d.month() == 3) {
targetDate = Date.newInstance(d.year(), 1, 1);
}
else if(d.month() == 4 || d.month() == 5 || d.month() == 6) {
targetDate = Date.newInstance(d.year(), 4, 1);
}
else if(d.month() == 7 || d.month() == 8 || d.month() == 9) {
targetDate = Date.newInstance(d.year(), 7, 1);
}
else {
targetDate = Date.newInstance(d.year(), 10, 1);
}
Only a portion of the code is included here.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm