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
yamini prakasam 10yamini prakasam 10 

can we write batch class without quering anything in start method

Best Answer chosen by yamini prakasam 10
Footprints on the MoonFootprints on the Moon
No, because start() method must return either Database.QueryLocator or Iterable<sObject>.
If we do not write anything in start(), it will give error as "Missing return statement required return type: System.Iterable<SObject>"

Moreover, execute() method accepts 2 arguments (Database.BatchableContext and List<sObject>). 
List<sObject> is received from start(), hence, we must atleast write a return statement inside start().

More reference - https://trailhead.salesforce.com/content/learn/modules/asynchronous_apex/async_apex_batch

All Answers

Footprints on the MoonFootprints on the Moon
  1. Batch class must implement Database.Batchable interface, which contains start() that must return either Database.QueryLocator object (result of query) or an Iterable that contains the records.
  2. Since we don't want to query anything in start method, return type cannot be Database.QueryLocator, it must be Iterable<sObject>
  3. We can create a list of any object inside start() method and return that list to execute() for actual processing. Hence, the answer to this question would be, Yes, we can write batch class without querying anything in start() method, provided we are returning a list of records.
  4. Some limitations not to query inside start() would be, the records to be processed have to be created ourselves instead of using existing records from the database. The usability of such a batch class would be greatly limited.
yamini prakasam 10yamini prakasam 10
but can we  directly insert record in execute method without writing anything in start method
Footprints on the MoonFootprints on the Moon
No, because start() method must return either Database.QueryLocator or Iterable<sObject>.
If we do not write anything in start(), it will give error as "Missing return statement required return type: System.Iterable<SObject>"

Moreover, execute() method accepts 2 arguments (Database.BatchableContext and List<sObject>). 
List<sObject> is received from start(), hence, we must atleast write a return statement inside start().

More reference - https://trailhead.salesforce.com/content/learn/modules/asynchronous_apex/async_apex_batch
This was selected as the best answer