0

I am using a SOQL like below

select COUNT(Transaction_Type_Id__c) tt, Id__c from Analysis_set_header__c group by Id__c

The Object having total 42 records.but I am getting error like

Aggregate query does not support queryMore(), use LIMIT to restrict the results to a single batch.

Here is my batch class

global class AnalysisSetWsCodeBatchClass implements Database.Batchable<sObject>,   Database.AllowsCallouts {

    public String query = 'select COUNT(Transaction_Type_Id__c) tt, Id__c from Analysis_set_header__c group by Id__c';
    global Database.QueryLocator start(Database.BatchableContext BC) {
        return Database.getQueryLocator(query);
    }

    global void execute(Database.BatchableContext BC, AggregateResult[] groupedResults) { 
        set<String> setAh = new set<String>();

        for (AggregateResult ar : groupedResults)  {
            System.debug('--------header---' + ar.get('Id__c'));
            setAh.add((string) ar.get('Id__c'));
        }
        system.debug('----------------setAh----------------------'+setAh);
        if(!setAh.isEmpty()){
            AnalysisSetCodeWsUpdate aw = new AnalysisSetCodeWsUpdate();
            aw.updateAnalysisSetCode(setAh);
        }
    }

    global void finish(Database.BatchableContext BC){
       //you can also do some after-the-job-finishes work here  
    }

}
Aacini
  • 65,180
  • 12
  • 72
  • 108
user989184
  • 141
  • 2
  • 6
  • 16

1 Answers1

0

how many records do you have when you query SELECT ID FROM Analysis_set_header__c? More than 43? My suggestion is to change your SOQL string to the following: SELECT COUNT_DISTINCT(Transaction_Type_Id__c) tt, Id__c from Analysis_set_header__c order by COUNT_DISTINCT(Id__c)