Skip to main content
added 22 characters in body
Source Link
Adrian Larson
  • 151.3k
  • 38
  • 247
  • 431

Use limit statement in query to avoid hitting governor limit... The modified query should look like-

Map<Id,Account> AccountToChangeRequest=new Map<Id,Account>([Select id,name,lastname,(Select Id,Updated__c,Lead_Merchant_Name__c,New_Value__c,Additional_Comments__c,Request_Type__c 
    from Change_Requests__r where Updated__c= False  and Lead_Merchant_Name__c!= NULL order by LastModifiedDate asc limit :Limit.getLimitQueryRows())from Account limit :Limit.getLimitQueryRows() - Limit.getQueryRows())];

Limit.getLimitQueryRows()Calling :Limit.getLimitQueryRows() will return maximum number of rows can be queried. Limit.getQueryRows() Calling :willLimit.getQueryRows() will return maximumcurrent usage.

Use limit statement in query to avoid hitting governor limit... The modified query should look like-

Map<Id,Account> AccountToChangeRequest=new Map<Id,Account>([Select id,name,lastname,(Select Id,Updated__c,Lead_Merchant_Name__c,New_Value__c,Additional_Comments__c,Request_Type__c 
    from Change_Requests__r where Updated__c= False  and Lead_Merchant_Name__c!= NULL order by LastModifiedDate asc limit :Limit.getLimitQueryRows())from Account limit :Limit.getLimitQueryRows() - Limit.getQueryRows())];

Limit.getLimitQueryRows() : will return maximum number of rows can be queried. Limit.getQueryRows() :will return maximum

Use limit statement in query to avoid hitting governor limit... The modified query should look like-

Map<Id,Account> AccountToChangeRequest=new Map<Id,Account>([Select id,name,lastname,(Select Id,Updated__c,Lead_Merchant_Name__c,New_Value__c,Additional_Comments__c,Request_Type__c 
    from Change_Requests__r where Updated__c= False  and Lead_Merchant_Name__c!= NULL order by LastModifiedDate asc limit :Limit.getLimitQueryRows())from Account limit :Limit.getLimitQueryRows() - Limit.getQueryRows())];

Calling Limit.getLimitQueryRows() will return maximum number of rows can be queried. Calling Limit.getQueryRows() will return current usage.

corrected spelling
Source Link

Use limit statement in query to avoid hitting governor limit... The modified query should look like-

Map<Id,Account> AccountToChangeRequest=new Map<Id,Account>([Select id,name,lastname,(Select Id,Updated__c,Lead_Merchant_Name__c,New_Value__c,Additional_Comments__c,Request_Type__c 
    from Change_Requests__r where Updated__c= False  and Lead_Merchant_Name__c!= NULL order by LastModifiedDate asc **limitlimit :Limit.getLimitQueryRows()**)from Account **limitlimit :Limit.getLimitQueryRows() - Limit.getQueryRows()**)];

Limit.getLimitQueryRows() : will return maximum number of rows can be queried. Limit.getQueryRows() :will return maximum

Use limit statement in query to avoid hitting governor limit... The modified query should look like-

Map<Id,Account> AccountToChangeRequest=new Map<Id,Account>([Select id,name,lastname,(Select Id,Updated__c,Lead_Merchant_Name__c,New_Value__c,Additional_Comments__c,Request_Type__c 
    from Change_Requests__r where Updated__c= False  and Lead_Merchant_Name__c!= NULL order by LastModifiedDate asc **limit :Limit.getLimitQueryRows()**)from Account **limit :Limit.getLimitQueryRows() - Limit.getQueryRows()**)];

Limit.getLimitQueryRows() : will return maximum number of rows can be queried. Limit.getQueryRows() :will return maximum

Use limit statement in query to avoid hitting governor limit... The modified query should look like-

Map<Id,Account> AccountToChangeRequest=new Map<Id,Account>([Select id,name,lastname,(Select Id,Updated__c,Lead_Merchant_Name__c,New_Value__c,Additional_Comments__c,Request_Type__c 
    from Change_Requests__r where Updated__c= False  and Lead_Merchant_Name__c!= NULL order by LastModifiedDate asc limit :Limit.getLimitQueryRows())from Account limit :Limit.getLimitQueryRows() - Limit.getQueryRows())];

Limit.getLimitQueryRows() : will return maximum number of rows can be queried. Limit.getQueryRows() :will return maximum

Source Link

Use limit statement in query to avoid hitting governor limit... The modified query should look like-

Map<Id,Account> AccountToChangeRequest=new Map<Id,Account>([Select id,name,lastname,(Select Id,Updated__c,Lead_Merchant_Name__c,New_Value__c,Additional_Comments__c,Request_Type__c 
    from Change_Requests__r where Updated__c= False  and Lead_Merchant_Name__c!= NULL order by LastModifiedDate asc **limit :Limit.getLimitQueryRows()**)from Account **limit :Limit.getLimitQueryRows() - Limit.getQueryRows()**)];

Limit.getLimitQueryRows() : will return maximum number of rows can be queried. Limit.getQueryRows() :will return maximum