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

system.exception too many query rows 501
can anybody explain me what is this error.I am trying to deploy a contoller class and visualforce page into production and i am geting this error.
system.limit.exception: Too many query rows 501.
The most likely reason is that you have some existing data in your production that isn't available in the sandbox. When you run your test classes during deployment, the total SOQL limit is being reached.
You could prevent this by using System.runAs()
More information can be found at :http://www.tgerm.com/2010/05/systemrunas-501-apex-query-rows.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+TechnologyGerm+(<Tech>+Germ)
Hope it helps!
hi Xhitman,
i tried using the system.runAs(). But still I am facing the same problem.
Have you tried checking the deployment log to see if you are reaching the limit?
Try to look for something like:
Number of query rows: 2392 out of 10000
i saw the deployment log i dont see anything like that saying
I use Limits.getLimitQueryRows to get passed this problem...limit your query by a integer set to this value, and then it will automatically limit test queries when you are deploying code without limiting queries when then run in Production
You could try @BritishBoyinDC's suggestion to explicitly show the current limits in the debug logs so that you will see how much you have used so far.
I also tried system.runAs() but negative.
The best solution is to run the test between starttest and stoptest.
test.test.startTest();
test.stopTest();
http://wiki.developerforce.com/index.php/An_Introduction_to_Apex_Code_Test_Methods
Sample Code:
test.startTest();
Your code
.....
......
test.stopTest();
cheers