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 6 years, 4 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

AI in Salesforce

Transform businesses with the power of Artificial Intelligence leveraged through Salesforce Einstein

Blog in

Artificial Intelligence is powering next-generation customer experiences with smart predictions, intelligent recommendations, timely automation and much more. Gartner predicts that by 2020, a staggering 85% of…

Popular Salesforce Videos