+ Start a Discussion
rajesh k 10rajesh k 10 

URgent:how to solve Too many SOQL queries: 101 ?

set<Id> proids=new Set<Id>();
            productList = [select id, name,Quantity__c from Product2 where Every_Bundle__c=TRUE];
            System.debug('&&&&conlist  &&&&&' + OptionalAdOnProductList);
            if (productList.size() > 0) {
                for (Product2 iterateproduct: productList) {
                    allProductsEveryBundleCheckboxcheckedList.add(new WrapperOfProducts(iterateproduct));
             List<PricebookEntry> listOfProductRelatedPricebookEntry=new List<PricebookEntry>();
             listOfProductRelatedPricebookEntry=[SELECT Product2Id,Pricebook2Id,UnitPrice FROM PriceBookEntry WHERE Product2Id IN :proids AND CurrencyIsoCode='USD'];
             for(PricebookEntry pricBkEntry :listOfProductRelatedPricebookEntry){
             Decimal Listprice=pricBkEntry.UnitPrice;

Help me...
kaustav goswamikaustav goswami
Can you please check the debug log and see where it is that the query is getting fored repeatedly. From the code snippet that you have pasted it is very difficult to understand as the query may be fired from anywhere within the complete apex transaction.

Waqar Hussain SFWaqar Hussain SF
The error is not in your that code, it is being called somewhere else which hits the limit of soql query which is that you can not query more that 100 in a one context. For more information have a look at this Site.
https://help.salesforce.com/apex/HTViewSolution?urlname=System-LimitException-Too-many-SOQL-queries-101&language=en_US (https://help.salesforce.com/apex/HTViewSolution?urlname=System-LimitException-Too-many-SOQL-queries-101&language=en_US)