You need to sign in to do that
Don't have an account?
steve456
Too many SOQL Queries--------Very Urgent
for(Order_Entry__c oe:oldOrderDetails)
{
if(oe.RecordTypeId==[Select Id from RecordType where Name='RKVZ' and SobjectType='Order_Entry__c'].Id)
if(oldOrderDetailMap.get(oe.Order_Number__c)==null)
{
oldOrderDetailMap.put(oe.Order_Number__c,new List<Order_Entry__c>{oe});
}
else
{
oldOrderDetailMap.get(oe.Order_Number__c).add(oe);
}
}
******************
Error is pointing to the highlighted line.....I know I have written a SOQL inside a for loop....How do i get red of this now........Very Urgent
You should not have query inside a for loop. this would invariably exceed the governor limits.
store the recordtype in a string. Have this before your for loop
and in the if statement compare it using the string
Hope this helps
Hi
Can u try inline soql query in place of red lines.?That way a list will be able to process more records than usual.
Thanks,
Trick
Yeah, what prady said. You always want to do queries outside of a loop.
You can even use collections for a query to reduce the number of SOQL queries.
Hi,
In your code there is Soql query in for loop thats why this error is coming..
put this soql statement outside for loop
RecordType re = [Select Id from RecordType where Name='RKVZ' and SobjectType='Order_Entry__c'];
for(Order_Entry__c oe:oldOrderDetails)
{
if(oe.RecordTypeId==re.Id)
if(oldOrderDetailMap.get(oe.Order_Number__c)==null)
{
oldOrderDetailMap.put(oe.Order_Number__c,new List<Order_Entry__c>{oe});
}
else
{
oldOrderDetailMap.get(oe.Order_Number__c).add(oe);
}
}