我正在使用如下所示的 SOQL
select COUNT(Transaction_Type_Id__c) tt, Id__c from Analysis_set_header__c group by Id__c
该对象总共有 42 条记录。但我收到如下错误
聚合查询不支持queryMore(),使用LIMIT将结果限制为单个批次。
这是我的批处理课程
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
}
}
查询 SELECT ID FROM Analysis_set_header__c 时,有多少条记录?超过43?我的建议是将您的 SOQL 字符串更改为以下内容: SELECT COUNT_DISTINCT(Transaction_Type_Id__c) tt, Id__c from Analysis_set_header__c order by COUNT_DISTINCT(Id__c)