function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Developer_shaanDeveloper_shaan 

Retrieve more than 1000 records using soql query.

This might be a silly question but i am unable to fix it.

I have an custom object created in sfdc which has more than 1000 records say 10000 records. But i am able to retrieve only 1000 records above that it is throwing an error , so how to  retrieve the 10000 records using soql query.

 

 Note: i dont want to apply limit here. I want to retrieve all the records.

 

Please let me know if any soln for this...

thanks

shaan

Anand@SAASAnand@SAAS

You cannot retrieve more than 10,000 records as that is a strict governor limit. If you are trying to do some processing on top of those records, i would suggest that you look at Apex batch to iterate over a very large number of records.

forecast_is_cloudyforecast_is_cloudy

Shaan - using the following syntax, you can retrieve a max of 10,000 (not 1000) records:

 

 

for(Account[] acts : [select id from Account])
{
    for (Account a : acts)
    {
       ....write your code here
    }
}

 The only way to process more than 10,000 records is via Batch Apex.

 

Pradeep_NavatarPradeep_Navatar

You can retrieve upto 10,000 recods, in batches in 200 (the implicit query more pattern).

 

                    for (List<Account> accts : [Select id from  account])

                   {

                          //The accts list will have 200 records at a time

                         for (Account a : accts)

                        {

                        …

                        }

                     }

Binh NgocBinh Ngoc

How about an soql to do that. I need to do that as I need to use PHP code from my website to query data from Salesforce.

Binh NgocBinh Ngoc

I have found it down. Just use queryMore()