質問の答えにできるようなシンプルなコードを準備しておきたいと思います。
Write a Batch Apex to Update all the Accounts with Industry as "Banking" to "Energy".
public class BAT_Update_Account implements Database.Batchable<sObject> {
public Database.QueryLocator start(Database.BatchableContext BC) {
// collect the batches of records or objects to be passed to execute
String query = 'Select Id,Name From Account where type =\'Banking\'';
return Database.getQueryLocator(query);
}
public void execute(Database.BatchableContext BC, List<Account> accList) {
System.debug('******** accList ' + accList);
List<Account> updateAccountList = new List<Account>();
for (Account a : accList ){
Account acc = new Account();
acc.Id = a.Id;
acc.Type ='Energy';
updateAccountList.add(acc);
}
try {
if(updateAccountList.size() > 0) update updateAccountList;
} catch(Exception e) {
System.debug(e);
}
}
public void finish(Database.BatchableContext BC) {
}
}