+ 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.