Wednesday 5 August 2015

Batch class

Global class Batchclass implements Database.Batchable<Account>, Database.Stateful{
    Integer i ;
    public List<Account> listofunits = new List<Account>();
 
    global Iterable<Account> start(Database.BatchableContext bc){
     
        listofunits = [ SELECT Id, Name FROM Account ];
        i=10;
        return listofunits;
    }
    global void execute(Database.BatchableContext bc, List<Account> scope){

       // List<Account> a = [Select Id From Account where Id =: ];
        for(Account acc : scope ){
            if(acc.Name == 'Reddy'){
                acc.Type = 'Customer - Channel';
            }
            i = i+1;
            system.debug('i.......' +i);
        }
     //   update scope;
        system.debug('acc - '+Scope);
        system.debug('Scope - ' +scope.size());
    }
    global void finish(Database.BatchableContext bc){
   //     system.debug('a..........' +a);
    }
}

No comments:

Post a Comment