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
ashish jadhav 9ashish jadhav 9 

Basic example of for loop for variable:SOQL & variable list: SOQL ?

Piyush Kumar 58Piyush Kumar 58
Hi Ashish,

SOQL for loops iterate over all of the sObject records returned by a SOQL query.
String s = 'Acme';
for (Account a : [SELECT Id, Name from Account
                  where Name LIKE :(s+'%')]) {
    // Your code
    a.Name = 'Oracle';
}
 



Please have a look on this:-https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_loops_for_SOQL.htm