function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
tulasiram chtulasiram ch 

Return types in batch class in apex

tulasiram chtulasiram ch
somebody asked me return types in batch apex , should i show this to him for searching answer for his question?   ... if u Dont mind tell me the clear answer...
Amit Chaudhary 8Amit Chaudhary 8
Are you looking for Database.executeBatch method returns Type
1) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm
The Database.executeBatch method returns the ID of the AsyncApexJob object, which you can use to track the progress of the job. For example:
ID batchprocessid = Database.executeBatch(reassign);

AsyncApexJob aaj = [SELECT Id, Status, JobItemsProcessed, TotalJobItems, NumberOfErrors 
                    FROM AsyncApexJob WHERE ID =: batchprocessid ];

If you are looking for Batchable Interface Method return type
2) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_interface_database_batchable.htm
Public System.Iterable start(Database.BatchabelContext bcon)
Public Database.QueryLocator start(Database.BatchabelContext bcon)
Public void execute(Database.BatchableContext bc,List<Sobject> scope)
Public void finish(Database.BatchableContext bc)

Let us know if this will help you

Thanks
Amit Chaudhary
Akash MishraAkash Mishra
Hi All,
Following is the link : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm
which is the answer to the question, which is List of sObject which a Start method in Batch Class returns...
Ram Sabarish 12Ram Sabarish 12
How is the Start method able to return two different return types? Iterable or QueryLocator. 

As far as Function Overloading is concerned, methods can be overloaded based on different input parameters. But its not possible to overload a method based on different Return Types.