Skip to main content
Hi 

How to make a batch apex run recursively ,i mean when ever we run a batch apex once it is finished ,it does not run again automatically,

so can someone help me about,how to run it continuously,

Below is my sample batch apex

public class BatchLeadDelete implements database.Batchable<sobject>

{

    list<lead> llist=new list<lead>();

    public string query='select id,name,Phone from lead';

    public string flag='12345';

    

    public database.querylocator start(database.BatchableContext bc){

       return database.getQueryLocator(query); 

  }

    public void execute(database.BatchableContext bc,list<lead> le){

        for(lead l:le){

            if(l.Phone==flag)

            {

                llist.add(l);

            }

                

        }

      delete llist;             

    }

    public void finish(database.BatchableContext bc){

        

    }

 }

calling the above class with below code

BatchLeadDelete l=new BatchLeadDelete();

    database.executeBatch(l,50);  
2 respuestas
  1. 8 jul 2015, 06:16
    write a schedule class which run for every one minuite . so the class will run recursively
0/9000