You need to sign in to do that
Don't have an account?
Mohidheen N
Apex batch class in batches issue
Hi ,
Can any one help me with the below .
I try to update all te account description with value "Testing 2" in my batches. I tried to update account description by picking 10 10 Acounts, But its updating only first 10 set of records and skipping remainign records.
Can you pls guide me where am wrong.
public class first_batch2_withuser_query implements Database.Batchable<sObject>{
public final String Field;
public final String Query;
public final String Value;
public first_batch2_withuser_query (String f, String q, String v){
Field =f; Query =q; Value =v;
}
public Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(Query);
}
public void execute(Database.BatchableContext BC, List<Account> Scope){
for (Account a: Scope){
a.put(Field,Value);
}
update Scope;
}
public void finish(Database.BatchableContext BC){
}
}
I tried with below methods but not updating all the accounts in batches.
String f='Description';
String q= 'Select Description from Account limit 10';
String v='Testing 2';
ID batchinstanceID= Database.executeBatch(new first_batch2_withuser_query(f,q,v),5);
String f='Description';
String q= 'Select Description from Account limit 10';
String v='Testing 2';
ID batchinstanceID= Database.executeBatch(new first_batch2_withuser_query(f,q,v));
String f='Description';
String q= 'Select Description from Account limit 10';
String v='Testing 2';
ID jobID= Database.executeBatch(new first_batch2_withuser_query(f,q,v));
Can any one help me with the below .
I try to update all te account description with value "Testing 2" in my batches. I tried to update account description by picking 10 10 Acounts, But its updating only first 10 set of records and skipping remainign records.
Can you pls guide me where am wrong.
public class first_batch2_withuser_query implements Database.Batchable<sObject>{
public final String Field;
public final String Query;
public final String Value;
public first_batch2_withuser_query (String f, String q, String v){
Field =f; Query =q; Value =v;
}
public Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(Query);
}
public void execute(Database.BatchableContext BC, List<Account> Scope){
for (Account a: Scope){
a.put(Field,Value);
}
update Scope;
}
public void finish(Database.BatchableContext BC){
}
}
I tried with below methods but not updating all the accounts in batches.
String f='Description';
String q= 'Select Description from Account limit 10';
String v='Testing 2';
ID batchinstanceID= Database.executeBatch(new first_batch2_withuser_query(f,q,v),5);
String f='Description';
String q= 'Select Description from Account limit 10';
String v='Testing 2';
ID batchinstanceID= Database.executeBatch(new first_batch2_withuser_query(f,q,v));
String f='Description';
String q= 'Select Description from Account limit 10';
String v='Testing 2';
ID jobID= Database.executeBatch(new first_batch2_withuser_query(f,q,v));
String q= 'Select Description from Account';
and execute the batch.
All Answers
String q= 'Select Description from Account';
and execute the batch.