+ Start a Discussion
Vinuthh SVinuthh S 

Too many SOQL Queries:101 in Webservice Class

Hi 

I geting the Too Many SOQL Queries:101 in below Line in webservice class

 List <Custom_Notification__c> notificationList = [SELECT Account_Id__c, Application_Id__c, Loan_App_Id__c, 
                                                              Message__c, Notify_Date__c 
                                                              FROM Custom_Notification__c
                                                              WHERE Account_Id__c =: accountId
                                                              AND User_Type__c =: account.Type
                                                              ORDER BY Notify_Date__c desc
                                                              LIMIT 3];

Thanks
Vinuthh S
Bhushan Patil 44Bhushan Patil 44
Hello Vinuth 
There is a DML limit of 100 DML so once you cross the DML limit you get the 'Too many SOQL Queries:101' Exception.I think you are doing a DML in a loop that's why you got this Exception.
can you paste your class here so i can assist you.

 
 
@GM@GM
Hi Vinuth,

are you doing any DML operation before that SOQL? if so, then triggers written on object on which DML happened will get execute and it might be close to limit of 100 and when it try to execute above SOQL then it might end up with crossing limit. Optimize the code if it’s due to this.

Put debug log before executing your web service and analyse it to get to know which all trigger executed, consumed limit to get to know where(&why) it caused the problem.

If the triggers are executing recursively then put static variable approach logic to avoid it.

Regards,
GM.