You need to sign in to do that
Don't have an account?
Keith Stephens 18
Bulkify help with soql query
Hello,
I have the follwoing code being executed in a for loop and I want to remove it from the loop and bulkify it how would I do this?
A list, or a map? I preferer to use a map if possible.
Thanks,
K
I have the follwoing code being executed in a for loop and I want to remove it from the loop and bulkify it how would I do this?
A list, or a map? I preferer to use a map if possible.
Account_Procedure_Rate__c rate = [SELECT Amount_To_Pay__c, Procedure_Cost__c FROM Account_Procedure_Rate__c WHERE CPT_Code__c = :proc.CPT_Code__c AND Main_Center__c = :centerId]; proc.Amount_To_Pay__c = rate.Amount_To_Pay__c; proc.Procedure_Cost__c = rate.Procedure_Cost__c;
Thanks,
K
You'd be left with Main_Center__c => CPT_Code__c => Account_Procedure_Rate__c record, where your for loop illustrated above could reference the map like this:
All Answers
The way you've written the SELECT, it appears you expect it to *always* return a single APR. The CPT_Code is unique within a Main_Center, and it is never missing. Right?
What are you looping over?
You'd be left with Main_Center__c => CPT_Code__c => Account_Procedure_Rate__c record, where your for loop illustrated above could reference the map like this: