function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kathyanikathyani 

System.Exception: Too many query rows: 540

SOQL query with 243 rows finished in 11 ms
System.Exception: Too many query rows: 540

Trigger.EmployeeTrigger: line 40, column 62


Below is line 40 in the code.
Map<ID, Employee__c> emps = new Map<ID, Employee__c>([select e.Id, e.Supervisor__c, e.Name from Employee__c e]);

Because of this when I say insert emp in my test method it displays the error "cannot insert update activity entity".

Can somebody please quickly help me?

thanks,
kathyani
Vijay RautVijay Raut
Hi,

There are many governor limits in apex (Trigger, Apex Method and Test Methods).

One of the limit is maximum number of record can be retrived in SOQL in context (it is 500 in case of Test Method).

Probably you need to use LIMIT in your SOQL like...if it is not braking your logic in code.

Map<ID, Employee__c> emps = new Map<ID, Employee__c>([select e.Id, e.Supervisor__c, e.Name from Employee__c e LIMIT 50]);

Hope this would help.

Cheers,
V.R.
jeffdonthemicjeffdonthemic
kathyani,

You might want to check out page #52 of the Winter 09 Apex Language reference. There's a section entitled, "Working with Very Large SOQL Queries" which might help depending on your exact situation. Not quite sure from your post.

You can download the doc at developer.force.com.

Jeff Douglas
Informa Plc
blog.jeffdouglas.com