You need to sign in to do that
Don't have an account?

Batch Apex
This is Bhaskar i am practicing SFDC i want to learn SFDC
How to use batch apex i am using this below code just copy and paste in apex classes page and runs it > it did not save
Apex Class Edit
error is came please any send how to use batch apex when we use batch apex to my mail id
:: bhaskar.anumolu@gmail.com::
9652964411
global class batchClass implements Database.batchable{
global Iterable start(Database.BatchableContext info){
return new CustomAccountIterable();
}
global void execute(Database.BatchableContext info, List<Account> scope){
List<Account> accsToUpdate = new List<Account>();
for(Account a : scope){
a.Name = 'true';
a.NumberOfEmployees = 70;
accsToUpdate.add(a);
}
update accsToUpdate;
}
global void finish(Database.BatchableContext info){
}
}
Hi,
You have to write dynamic query within Start method and then do the return via
Database.QueryLocator(DynamicQuery);
For reference please go through this
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_batch_interface.htm
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks
Hi Bhaskar/Souvik,
As you can see in the link provided by Souvik,
The start method collects the records or objects to be passed to the interface method execute.
It returns either a Database.QueryLocator object or an iterable that contains the records or objects being passed into the job.
In your case, you will have to use Custom Iterators
Heres more info on the same
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_iterable.htm
Btahc apex example for you:
http://cloudforce4u.blogspot.in/2013/07/batch-apex-example.html