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
prabhakar r 3prabhakar r 3 

iterable example .Total salry of(6000) all records.and batch size is 3000 how we can write in iterabl

How we can get if 6000 records-salry can adding.Total salry of all records.and batch size is 3000 how we can write in iterable
Please Help Me...
KaranrajKaranraj
Can you gives us little more details what you are trying to do. Are you looking for custom iterators in batch class. https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_iterable.htm
prabhakar r 3prabhakar r 3
karnraj ...custim iterator in batch class..within batch apex class program using iterable..my requirment is one of the employee object having 6000 records.that object havng salry field..all the Total 6000 records salary.i want sum of salary all records..how we can do...
James LoghryJames Loghry

Prabhakar,

You can do this in a batch, if you implement the Database.Stateful interface.  That being said, if you're only running through 6000 records, a simple Apex class that does a SOQL query and sums up the values should be sufficient.

For the batch scenario, Salesforce docs has an example of exactly what you're looking for here: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_batch_interface.htm (See the Database.Stateful example)