+ Start a Discussion

retrieving records more than 10000 from an soql query



Is there any way to retrieve records more than 10000(ex: 30000) from an object in apex.

Can we make use of @future to retriev ethe records if yes whats the approach?


To be more clear i ahve an example:


List<Contact> ListCntct = [select name from contact where accountID = Account.ID];


Thanks in Advance






Normal Apex Code is limited to 10,000 rows. You can use a StandardSetController to query a large number of records through a Visualforce component, or use Batch Apex to process a large number of records in an asynchronous process. What exactly are you attempting to do?


Go through the sample code given below to retrieve more than 10000 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];



            for(List<Account> ListA : ListListAcc){

                for(Account ac : ListA){  // Display account records} }