You need to sign in to do that
Don't have an account?
Batchable<SObject> Interface: Isn't it an unusual interface?
If you look at the general approach to write a batch, it asks to implement the Batchable interface. The sample code is like this -
Also, Salesforce doc says you need to implement start method -
In a nutshell, how has salesforce written the Batchable interface?
global class Accountupdate implements Database.Batchable<sObject> { : :Here, one thing is absurd - what is the use of datatype sObject in the interface name? Can we write an interface like this?
Also, Salesforce doc says you need to implement start method -
global (Database.QueryLocator | Iterable<sObject>) start(Database.BatchableContext bc) {}But in an interface how can you define a method with 2 return types? Again, when you actually implement this, you are implementing with just any one of these return types - Database.QueryLocator or Iterable<sObject>. How does this work?
In a nutshell, how has salesforce written the Batchable interface?
Salesforce tells to use any one of them not both return types in for start() method. The below will work.
global Database.QueryLocator start(Database.BatchableContext bc) {
}
Please check below links which will help you.
https://developer.salesforce.com/forums/?id=906F00000008m2xIAA
https://webkul.com/blog/batch-apex/
Thanks,
Hello,
global class LeadProcessor implements Database.Batchable<sObject>
It's a syntax of batch apex