You need to sign in to do that
Don't have an account?

Too many sql queries while executing text class
Hello,
I have below piece of code, which worked well for 1 month and the test class was also sucessful.
Wheni check it again it gevew, Too many sql queries error for a line.
When i execute this line in Execute query then it returns only 15 rows, i have no idea why it fails
I have below piece of code, which worked well for 1 month and the test class was also sucessful.
Wheni check it again it gevew, Too many sql queries error for a line.
When i execute this line in Execute query then it returns only 15 rows, i have no idea why it fails
List temp = new List(); try{ temp = [SELECT EFX_Category__c FROM ProfileSkill where EFX_Type__c ='Certifications' ORDER BY EFX_Category__c] ; }Catch(DmlException de ){ System.debug(de); }
When ar eyou getting this error ?
If you are getting while executing test class then,
Please check one thing in your test method may be you don't have Test.startTest() and Test.stopTest() .
Also one thing you need to change the exception ,as you have simply qury in try block you need to catch QueryException instaed of DmlException .
As your query is not inside for loop ,also you don't have trigger and your code is in class .You need to wrap Test.startTest() and Test.stopTest() in test methods .
Please let me know if it helps .
Thanks
Manoj
All Answers
Do you have any SOQL inside trigger?
Thanks,
Himanshu
You need to provide more of your code for us to evaluate. Typically this will occur if you have a Select within a loop.
TDM
Select is also not in For loop its in If condition but this wont be a loop
When ar eyou getting this error ?
If you are getting while executing test class then,
Please check one thing in your test method may be you don't have Test.startTest() and Test.stopTest() .
Also one thing you need to change the exception ,as you have simply qury in try block you need to catch QueryException instaed of DmlException .
As your query is not inside for loop ,also you don't have trigger and your code is in class .You need to wrap Test.startTest() and Test.stopTest() in test methods .
Please let me know if it helps .
Thanks
Manoj
Any reason for this cause.
Not able to catch you properly how you have splited your test class . May be you have added stsrtTest and stopTest in your code .