+ Start a Discussion
Rajendra Prasad 44Rajendra Prasad 44 

can i pass LIMIT statement as a parameter in SOQL

Greg CooganGreg Coogan
If you mean a SOQL query in Apex, then Yes. Here is an example of passing a limit to a query of Contact for a list.
 
Integer qryLimit = 10;

List<Contact> cont = [
SELECT Id, Name
FROM Contact
LIMIT :qryLimit
];

 
Deepali KulshresthaDeepali Kulshrestha
Hi Rajendra,


Please check below code:
 
public class Test {

    public static void testQuery(Integer queryLimit)
    {

      List<Account> acc = [SELECT Id, Name FROM Account LIMIT : queryryLimit];
      System.debug('Account list is ::::'+acc);
        
    }
}


I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com
 
Rajendra Prasad 44Rajendra Prasad 44
Thank you for your response
Rajendra Prasad 44Rajendra Prasad 44
Thank you for your reply