+ Start a Discussion
sk kumarsk kumar 

batch apex code showing error...!!

// hi..here in my batchapex code logic is to update the name,description field from account....so saving this i got error like:

Error: Compile Error: expecting a right parentheses, found 'info' at line 2 column 69 ........anyone help me in this regard. //

 

 

 

global class batchclass implements Database.batchable<sobject>

   {
        global Database.Querylocator start(Database.Batachable contextinfo)

      {
        string query='select id,name,description from account';
        return Databse.getQuerylacator(query);
         }
         global void execute(Database.Batchable contextinfo,list<account>accountlist);
         list<acccount>acctoupdate=new list<account>();
         for(account a:accountlist)
             {
                if(description==null)
                 {
                    a.description='batch apex';
                   acctoupdate.add(a);
                           }
                    }
                update acctoupdate;
                    }
      global void finish(Database.Batchablecontextinfo){

                       
                      }
        }

Abhi_TripathiAbhi_Tripathi

Hi,

 

You have alot of mistakes in your code

Save this one, please refer salesforce post of batches for more knowledge

 

global class batchclass implements Database.batchable<sobject>, Database.Stateful {

global Database.Querylocator start(Database.BatchableContext BC) {

String query = 'Select Id, Name, Description from Account';

return Database.getQuerylocator(query);
}
global void execute(Database.BatchableContext BC, List<Account> accountlist) {

List<Account> acctoupdate = new List<Account>();

for(account a:accountlist)
{
if(a.description==null)
{
a.description='batch apex';
acctoupdate.add(a);
}
}
update acctoupdate;
}
global void finish(Database.BatchableContext BC){

}
}

 

Force TechieForce Techie

Hi SK,

 

In Batch class code "Start" method have an argument of "Database.BatchableContext" instance please do this in your code:

 

 global Database.Querylocator start(Database.BatchableContext info)

      {

//Your logic

}