Activity Forums Salesforce® Discussions What is the difference between database.querylocator and Iterator list in Salesforce? What are their use cases?

  • Adarsh

    Member
    January 11, 2018 at 2:20 pm

    Hi Shubhendu,

    As per our DataSet which is going to be executed, we need to decide this.

    Database.querylocator - If we need the filtered record in our DataSet, means if you want to run the batch on records that can be filtered by SOQL then QueryLocator is preferable.A maximum of 50 million records can be returned in the Database.QueryLocator object

    Iterator list - An iterator traverses through every item in a collection. For example, in a while loop in Apex, you define a condition for exiting the loop, and you must provide some means of traversing the collection, that is, an iterator. In the following example, the count is incremented by 1 every time the loop is executed (count++) :

    Hope it helps 🙂

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos