• #30981
    Forcetalks

    What is database.getQuerylocator in Salesforce?

    What is database.getQuerylocator in Salesforce?

    Tagged: , , , ,

    #31244
     Prachi #7
    Forcetalks

    Hello Avnish,

    Database.getQueryLocator returns a Query Locator that runs your selected SOQL query returning list that can be iterated over in bathc apex or used for displaying large sets in VF (allowing things such as pagination).

    The query locator can return upto 50 million records and should be used in instances where you want to bactha 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.

    Hope that helps.

    Thanks.

    #34581
    Salesforce | shariq shariq #1
    Forcetalks

    Hi,

    Database.QueryLocator object when you are using a simple query (SELECT) to generate the scope of objects used in the batch job. If you use a querylocator object, the governor limit for the total number of records retrieved by SOQL queries is bypassed but we can retrieve up to 10,000 records.

    To add more –

    Database.query():

    We can retrieve up to 50,000 records.
    If VF page has read-only attribute, use Database.getQueryLocator().
    In Batch Apex, if we use Database.query(), it supports 50,000 records only.

    String fieldName = ‘Name,Phone’;
    String dynQuery = ‘select Id ‘ + fieldName + ‘ From Account’;
    Database.query(dynQuery);

    Hope this helps.

    #34596
    Salesforce | Parul Parul #2
    Forcetalks

    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

     

    Thanks

Viewing 4 posts - 1 through 4 (of 4 total)

Please to reply to this topic.

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending

About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2018 Forcetalks. All Right Reserved.

Log in with your credentials

or    

Forgot your details?