You need to sign in to do that
Don't have an account?
oleg.tuchscherer
Apex Batch working with LIST ?
Hi,
i have an apex batch for deleting different types of data.
So i have 3 objects (no releations to each other).
In the start method i build 3 search strings and would like to let run the execute method 3 times.
How to do that?
The following structure does not work:
global database.querylocator start(Database.BatchableContext bc){
for(String query : batchHelper.buildSearchStrings())
return Database.getQueryLocator(query);
}
Thank you for the help!
for(String query : batchHelper.buildSearchStrings()) {
BatchClass b = new BatchClass();
b.Query = query;
database.executebatch(b);
}
All Answers
for(String query : batchHelper.buildSearchStrings()) {
BatchClass b = new BatchClass();
b.Query = query;
database.executebatch(b);
}
Thanks !
Batch is also runnning in schedulable context. So i put your code in schedulable execute, like the following:
global void execute(SchedulableContext SC) {
for(String query : batchHelper.buildSearchStrings())
f42_Batch_DeleteData b = new f42_Batch_DeleteData();
b.Query = query;
Database.executeBatch(b);
}
}
what is to do with the START method ?
global database.querylocator start(Database.BatchableContext bc){
return ???;
}
return database.getQueryLocator(database.query(query));
Regards,
Bhavi Sharma
Certified Salesforce Consultant
bhavi@simplyforce.com/bhawani.sh.sharma@gmail.com
+91-9928130589
LinkedIn |
Twitter
| Blog |
Community
www.simplyforce.com