+ Start a Discussion
Claire SunderlandClaire Sunderland 

I want to comment out an Apex Class batch that I have written b/c I don't want it running currently.

When I use /*   */ it get an error --> Error: Compile Error: Unexpected EOF at line 21 column 1.  Can someone tell me why this is?  Here is the code.


global class DeleteAllTask implements Database.Batchable<Sobject>,schedulable{
          
    global Database.queryLocator start(Database.BatchableContext bc)
    {
        String sSOQL = 'Select ID, Status, Subject From Task Where status =\'Completed\' and subject=\'callback\' ' ; 
        if(test.isRunningTest()){
            sSOQL += ' limit 5 ';
        }
            return Database.getQueryLocator(sSOQL);
    }
    global void execute(Database.BatchableContext bc, List<Task> scope){
        Delete scope;
    }            
        global void finish(Database.BatchableContext bc){
    }
        global void execute(SchedulableContext sc){
            DeleteAllTask oDeleteAllTask = new DeleteAllTask();
            Database.executeBatch(oDeleteAllTask,50);
    }
}
Hemant_SoniHemant_Soni
Hi Claire,
You can comment a batch like we are commenting class.Because batch implements interfaces and it need his method to compile.
So can do like below so your batch will not work.
global class DeleteAllTask implements Database.Batchable<Sobject>,schedulable{
          
    global Database.queryLocator start(Database.BatchableContext bc)
    {
        String sSOQL = 'Select ID, Status, Subject From Task Where status =\'Completed\' and subject=\'callback\' ' ; 
        if(test.isRunningTest()){
            sSOQL += ' limit 5 ';
        }
            return Database.getQueryLocator(sSOQL);
    }
    global void execute(Database.BatchableContext bc, List<Task> scope){
        Delete scope;
    }            
        global void finish(Database.BatchableContext bc){
    }
        global void execute(SchedulableContext sc){
           // DeleteAllTask oDeleteAllTask = new DeleteAllTask();
           // Database.executeBatch(oDeleteAllTask,50);
    }
}
If this helps you please mark it solved.
Thanks
Hemant