Activity Forums Salesforce® Discussions What is the difference between Database.queryLocator and Iterable in the Batch?

  • What is the difference between Database.queryLocator and Iterable in the Batch?

    Posted by Shweta on June 16, 2020 at 3:01 pm

    What is the difference between Database.queryLocator and Iterable in the Batch apex?

    MOHIT replied 4 years, 5 months ago 2 Members · 1 Reply
  • 1 Reply
  • MOHIT

    Member
    June 17, 2020 at 9:00 am

    "Difference between Database.QueryLocator() and Iterable in BatchApex?" - The answer depends on your need, if you want to run a batch on records that can be filtered by SOQL then QueryLocator is preferable, but if records that you want to be processed by batch cannot be filtered by SOQL then you will have to use Iterable. But most of the cases it will be achieved by query locator, so query locator is preferable so just try with it if you scope is complex and can not be achieved by SOQL then go with Iterable.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos