I was just wondering is it possible to class executeBatch method of two different Batchable classes inside the execute method of a Schedule class. For example;
global class BatchClassA implements Database.Batchable<sObject>
{
global Database.QueryLocator start(Database.BatchableContext BC)
{
//query goes here;
}
global void execute(Database.BatchableContext BC, List<Child__c> scope)
{
//execution goes here
}
global void finish(Database.BatchableContext BC)
{
}
}
global class BatchClassB implements Database.Batchable<sObject>
{
global Database.QueryLocator start(Database.BatchableContext BC)
{
//query goes here;
}
global void execute(Database.BatchableContext BC, List<Child__c> scope)
{
//execution goes here
}
global void finish(Database.BatchableContext BC)
{
}
}
global class Scheduler_class implements Schedulable{
global void execute(SchedulableContext sc) {
BatchClassA b1 = new BatchClassA();
ID batchprocessidA = Database.executeBatch(b1);
BatchClassB b2 = new BatchClassB();
ID batchprocessidA = Database.executeBatch(b2);
}
}
If there are more than 2 Million records(both batch class have to handle more than 2 million records in one go individually), will this work? What about the governor limits?
or the scheduler class should be different for both of the batch classes?
global
...global
modifier unless you are building an API on the platform (webservice
orApexRest
) or if you are developing a managed package. You are doing neither in this case.