global class batchAccountInsert implements database.Batchable<sObject> {
global Database.Querylocator start(Database.BatchableContext bc) {
String query = 'select Name,Industry from Account';
return database.getQueryLocator(query);
}
global void execute(Database.BatchableContext bc , List<Account> scope) {
List<Account> AccountToInsert = new List<Account> {};
for (Account a : scope) {
Account newAcc = new Account();
System.debug('Account Industry[' + a.Industry + '], Name[' + a.name + ']');
newAcc.Name = a.Name + ' ' + 'Hello' ;
newAcc.Industry = a.Industry;
AccountToInsert.add(newAcc);
}
insert AccountToInsert;
}
global void finish(Database.BatchableContext bc) {
}
}
here return database.getQueryLocator(query)
can return total records which are present in Account object, so only that number of new records can be created, what if I want to create more than 20K new records. what should be the initialization in start method for this?