- August 3, 2018 at 12:37 pm #30981Avnish Yadav #3
What is database.getQuerylocator in Salesforce?
What is database.getQuerylocator in Salesforce?August 8, 2018 at 6:54 am #31244Prachi #9
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.September 16, 2018 at 5:15 pm #34581shariq #1
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 –
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’;
Hope this helps.September 16, 2018 at 5:46 pm #34596
Please Register to reply to this topic. /