+ Start a Discussion
Prady01Prady01 

How to retrieving more than 10K records

I have page, Which inturn contains picklists like category when I select one category then the data related to that catogory must be displayed in the table.. Which is all working fine (page/class)but I am getting an error saying ,Too many query rows: 10001.. So can anyone, help me work around this problem...  

Best Answer chosen by Admin (Salesforce Developers) 
Pradeep_NavatarPradeep_Navatar

Use nested List to fetch more than 10K records :

 

            List<List<Account>> ListListAcc = New List<List<Account>>();

            List<Account> ListAcc;

 

            for(Integer i=0; i<5; i++)

            {

                        ListAcc = [Select id, name From Account limit 10000];

                        ListListAcc.add(ListAcc);

            }

 

            for(List<Account> ListA : ListListAcc)

            {

                        for(Account ac : ListA)

                        {

                                    // Display account records

                        }

            }

All Answers

Ispita_NavatarIspita_Navatar

The solution to your issue lies in using javascript API.

Pradeep_NavatarPradeep_Navatar

Use nested List to fetch more than 10K records :

 

            List<List<Account>> ListListAcc = New List<List<Account>>();

            List<Account> ListAcc;

 

            for(Integer i=0; i<5; i++)

            {

                        ListAcc = [Select id, name From Account limit 10000];

                        ListListAcc.add(ListAcc);

            }

 

            for(List<Account> ListA : ListListAcc)

            {

                        for(Account ac : ListA)

                        {

                                    // Display account records

                        }

            }

This was selected as the best answer
_Prasu__Prasu_

Hello Pradeep,

 

Will List doesnt support records over 1000, so query limit should be 1000 and not 10000? Am I right?

Pradeep_NavatarPradeep_Navatar

Limits on the number of items in a collection has been removed in Spring 10. However, there's still a general limit on heap size.

_Prasu__Prasu_

Thanks alot Pradeep!!

Amar Kumar 42Amar Kumar 42
Check the Latest Updated information on the Latest State and Central Government schemes at 
Sarkari Yojana (https://www.sarkariyojnaa.com/)