Activity Forums Salesforce® Discussions what is the Use of database.querylocator in Salesforce?

  • what is the Use of database.querylocator in Salesforce?

    Posted by Shubham on January 21, 2020 at 4:56 PM

    What is the use of Database.querylocator in batch apex?

    • This discussion was modified 6 years ago by  Shubham.
    Ratnesh replied 6 years ago 3 Members · 2 Replies
  • 2 Replies
  • Kirandeep

    Member
    January 21, 2020 at 5:25 PM

    Database.getQueryLocator in Salesforce returns a Query Locator that runs your selected SOQL query returning list that can be iterated over in batch apex or used for displaying large sets in VF.

  • Ratnesh

    Member
    January 21, 2020 at 5:36 PM
    • Database.getQueryLocator returns a Query Locator that runs your selected SOQL query returning list that can be iterated over in batch apex.
    • The query locator can return up to 50 million records
    • It should be used in instances where you want to batch a high volume of data up (pagination or batch apex).
    • The database.query method should be used in instances where you are wanting to do a dynamic runtime SOQL query for your code.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos