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
minkeshminkesh 

Too many query locator rows: 10001

Hi,

     I am in big trouble and i don't why this error comes.

     can anybody help me in this matter ? 

    I am facing the error Too many query locator rows: 10001. i have put limit  10000 in the query than also this error comes.

    Please help me.

raseshtcsraseshtcs

Could you provide the code please.

minkeshminkesh

Hi,

     Thank you for your response here is my piece of code please refer and let me know:-

    

            /*************************Sorting ends ***********************************************/

            /*************************fetch Records starts ***********************************************/
            //begin filter contents

            Id accId= controllerAccount.Id;
            
            String SQL_SELECT = null;
            if ( UtilityController.isMultiCurrency() ) {
                str = str.replace('CurrencyIsoCode,', '');
                str = str.replace('currencyisocode,', '');
                SQL_SELECT = 'Select CurrencyIsoCode ,'+ str + ' From Dispute__c where  Account__c = :accId ';

            } else {

                SQL_SELECT = 'Select '+ str + ' From Dispute__c where  Account__c = :accId ';

            }

            String SECOND_SORT = '';
            if(secondaryColumnToSort != null && secondSortFieldName != '') {
                if(secondaryColumnToSort == previousSecondColumnToSort) {
                    if(secondaryOrderType == 'ASC')
                        secondaryOrderType = 'DESC';
                    else
                        secondaryOrderType = 'ASC';
                }
                SECOND_SORT = ' ,'+secondSortFieldName+' '+secondaryOrderType;
            }

            String SQL_ORDERBY = ' order by ' + sortFieldName +   ' ' + orderType + sortFieldName1 + ' ' +SECOND_SORT+ ' Limit 10000';

            String SQL_INCLUDE_CLAUSE = '';

            if(showCloseDisputes)
            {
                SQL_INCLUDE_CLAUSE += ' and ( ';
                SQL_INCLUDE_CLAUSE += '(Balance__c = 0) ';
            }
            else
            {
                SQL_INCLUDE_CLAUSE += ' and ( ';
                SQL_INCLUDE_CLAUSE += '(Balance__c != 0) ';
            }

            if(SQL_INCLUDE_CLAUSE != '')
            {
                SQL_INCLUDE_CLAUSE += ' )';
            }

            String SOQLQuery = SQL_SELECT + SQL_INCLUDE_CLAUSE + SQL_ORDERBY;
            //end filter contents
            con = new ApexPages.StandardSetController(Database.getQueryLocator(SOQLQuery ));
            if( con.getResultSize() > 0) {
                totalDisputes = con.getResultSize();
                if(totalDisputes >2000) {
                    displayTotalRec ='2000+';
                }else{
                    displayTotalRec = string.valueOf(totalDisputes);
                }
                con.setPageSize(Integer.valueOf(disputeRecPerPage));
                if(isNoteAction == true) {
                    con.setPageNumber(pgNumber);
                }else{
                    con.setPageNumber(1);
                }
                getWrapList();
            }else{
                totalDisputes = 0;
                displayTotalRec ='0';
            }

 

raseshtcsraseshtcs

Could it be that the limit is cumulative of some other queries you have made in the code... Also found this

http://boards.developerforce.com/t5/Apex-Code-Development/limit-of-10000-query-rows-in-APEX-class/td-p/278947... This suggests to check and increase the version of the class.