You need to sign in to do that
Don't have an account?
Can batch.execute be called directly?
The regular approach to execute batch job is use " Database.executeBatch", can batch.execute be called directly? if so, any special attention needed? say I have a batch class like
global without sharing class BatchA implements Database.Batchable <sObject>{
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator([select ID from Account]);
}
global void execute(Database.BatchableContext BC, List<sObject> scope){
...
}
global void finish(Database.BatchableContext BC) {
}
}
Is it safe to call like
BatchA myBatch = new BatchA();
myBatch.execute(NULL, [select id from account limit 100]);
It shouldn't cause any problems to call it directly. It's simply a class that implements the batchable interface.
All Answers
It shouldn't cause any problems to call it directly. It's simply a class that implements the batchable interface.