You need to sign in to do that
Don't have an account?
Keith Stephens 18
Aggregate query does not support queryMore(), use LIMIT
Hello All,
I hope someone can help me or point me in the right direction to solve this error I am getting.
This error is occuring on this line:
I think it is due to it's bringing back to many rows.
Would this line of code resolve such issue?
Sticking it into a list of sobject? If so what is the difference between the two?
This only occures in our production environment since we do not keep our dev and qa upto date with this many records ect..
Thanks,
Keith.
I hope someone can help me or point me in the right direction to solve this error I am getting.
This error is occuring on this line:
AggregateResult[] AARsAB = [SELECT Count(id) maxRates, Main_Center__c,CPT_Code__c FROM Account_Procedure_Rate__c where Main_Center__c IN: centerMap.keySet() group by CPT_Code__c, Main_Center__c];
I think it is due to it's bringing back to many rows.
Would this line of code resolve such issue?
List<SObject> AARs= [SELECT Count(id) maxRates, Main_Center__c,CPT_Code__c FROM Account_Procedure_Rate__c group by CPT_Code__c, Main_Center__c];
Sticking it into a list of sobject? If so what is the difference between the two?
This only occures in our production environment since we do not keep our dev and qa upto date with this many records ect..
Thanks,
Keith.
A run-time exception occurs if you use a query containing an aggregate function that returns more than 2,000 rows in a for loop and that is happening in your case.
You need to limit the number of rows that the AggregateResult retrieved or you may try to process all the records, use asynchronous calls/Batch so that you can process all the record in small batch.
Again List may not help if you are looping through the list and you may hit the exception "Aggregate query has too many rows for direct assignment, use FOR loop" so I would suggest go for Batch job.
--
Thanks,
Prashant
Thanks for your reply, but how do I do this?
Can anyone help in re-writting this trigger the correct way?
Thanks,
K.
Well in order to achieve this, You need to implement an Iterable batch class and call this class into your trigger. Check this url for sample batch class.
https://help.salesforce.com/articleView?id=000192834&language=en_US&type=1
//Gets a count of the rates and adds them to a map using Key Value pairs/
037 //Key (CPT Code, Center) Vaue (maxRates)
038 AggregateResult[] ARs = [SELECT Count(id) maxRates, Center__c,CPT_Code__c
039 FROM Center_Procedure_Rate__c group by CPT_Code__c, Center__c];
Thanks,
Keith.