You need to sign in to do that
Don't have an account?
Pranav Sanvatsarkar
LIMIT is not working in my SOQL query
I am trying to run this snippet in Developer Console,
Thanks in advance!
Set<Id> setProdIds = new Set<Id>(); for( Product2 prod : [ SELECT Id FROM Product2 WHERE Division__c IN ('SIOUX FALLS','RAPID CITY')]) setProdIds.add(prod.Id); Set<Id> setOppIds = new Set<Id>(); for( Integer iCount = 0; iCount <= 28; iCount++ ) { List<OpportunityLineItem> lstLineItems = [SELECT OpportunityId FROM OpportunityLineItem WHERE Product2Id IN: setProdIds AND Id NOT IN: setOppIds LIMIT 25000]; system.debug('Size of list:'+lstLineItems); for( OpportunityLineItem lineItem : lstLineItems ) setOppIds.add(lineItem.OpportunityId); } List<Opportunity> lstOpportunities = [SELECT Id FROM Opportunity WHERE Division__c IN ('SIOUX FALLS','RAPID CITY') AND Id IN: setOppIds LIMIT 25000]; system.debug('Total opps to migrate:'+lstOpportunities.size());Now, even if I have kept the LIMIT 25000, it throws error "System.LimitException:50001 rows".
Thanks in advance!
Line no 2 can also give the error as there is no limit in the query...please check ..
As a best practise we should not use for inside for and SOQL inside for..in your code you have used both inside for..that will always hit the limits..Please optmize your code ..
Thanks,
Sandeep
Since you are running the SOQL Select statement inside the for loop. Take out the Select statement from for loop.
2. I needed to run SOQL queries in FOR LOOP only, because I can get 50000 records at a time. I need to access 700000 records of OpportunityLineItems. The code is already optimized to take care of all governor LIMITS!
Can you provide any other solution?
Hi, sandeep sankhla
my requirement is creating visualforce page when i click sumbit button new user should be created. but i need now user enter a values click submit button it will be display on error message.give one example for user object.How to solve that one please give any ideas
Hi, pranav_sanvatsarkar
my requirement is creating visualforce page when i click sumbit button new user should be created. but i need now user enter a values click submit button it will be display on error message.give one example for user object.How to solve that one please give any ideas