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
AttaridAttarid 

Save Lists to session variable or view state

Hi,

 

Is there anyway to save lists to session variable or view state.

I am getting System.Exception: Too many SOQL queries: 101 when I run a particual routine which has

SOQL in a loop multiple times.

Thanks.

aalbertaalbert

My recommendation is to move the Queries outside of the FOR loops. Query for all related data outside the for loops, process the results and logic inside the for loops, then also perform DML operations outside of for loops. Those simple concepts will help avoid governor limits. Lastly, you can use the @future annotation to get higher governor limits but those methods will run asynchronously. 

Message Edited by aalbert on 03-09-2009 09:00 AM
AttaridAttarid

I am actually summing up some data and the only way to do it is in a loop.

so I was hoping if someone knew how to persist list data so I wouldn't have to call the same routine with

SOQL in a loop multiple times.