Here, the second param in the executeBatch method (the value 1) is the scope ; it means you want the batch to handle the elements 1 by 1. For instance, if the batch has to deal with 10 elements, the execute method will executes 10 times.
Here, the first param is your batch class, the second is the scheduled job title, the third is the time in minutes after which the job will start, and the last is the scope.
Handling elements little by little is very useful, because each time the execute method executes, the governor limits are reseted. But careful, if you want to keep state in your batch apex, you will need to implement Database.Stateful. Problem is : governor limits are not reseted.
Here, the second param in the executeBatch method (the value 1) is the scope ; it means you want the batch to handle the elements 1 by 1. For instance, if the batch has to deal with 10 elements, the execute method will executes 10 times.
Here, the first param is your batch class, the second is the scheduled job title, the third is the time in minutes after which the job will start, and the last is the scope.
Handling elements little by little is very useful, because each time the execute method executes, the governor limits are reseted. But careful, if you want to keep state in your batch apex, you will need to implement Database.Stateful. Problem is : governor limits are not reseted.
the start method excutes once, at the begining.
For the execute method, it depends on you.
You can launch it through an Apex command :
Database.executeBatch(new nameOfYourBatchClass(optionalParamInConstructor), 1);
Here, the second param in the executeBatch method (the value 1) is the scope ; it means you want the batch to handle the elements 1 by 1.
For instance, if the batch has to deal with 10 elements, the execute method will executes 10 times.
You can also schedule it :
System.scheduleBatch(new nameOfYourBatchClass(optionalParamInConstructor), 'job example', 5, 1);
Here, the first param is your batch class, the second is the scheduled job title, the third is the time in minutes after which the job will start, and the last is the scope.
Handling elements little by little is very useful, because each time the execute method executes, the governor limits are reseted. But careful, if you want to keep state in your batch apex, you will need to implement Database.Stateful. Problem is : governor limits are not reseted.
I invite you to read the Salesforce documentation here : http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_batch_interface.htm (http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_batch_interface.htm" target="_blank), it is very useful to understand how to use batch apex, and to understand all the limits of it.
Hope it helped
All Answers
the start method excutes once, at the begining.
For the execute method, it depends on you.
You can launch it through an Apex command :
Database.executeBatch(new nameOfYourBatchClass(optionalParamInConstructor), 1);
Here, the second param in the executeBatch method (the value 1) is the scope ; it means you want the batch to handle the elements 1 by 1.
For instance, if the batch has to deal with 10 elements, the execute method will executes 10 times.
You can also schedule it :
System.scheduleBatch(new nameOfYourBatchClass(optionalParamInConstructor), 'job example', 5, 1);
Here, the first param is your batch class, the second is the scheduled job title, the third is the time in minutes after which the job will start, and the last is the scope.
Handling elements little by little is very useful, because each time the execute method executes, the governor limits are reseted. But careful, if you want to keep state in your batch apex, you will need to implement Database.Stateful. Problem is : governor limits are not reseted.
I invite you to read the Salesforce documentation here : http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_batch_interface.htm (http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_batch_interface.htm" target="_blank), it is very useful to understand how to use batch apex, and to understand all the limits of it.
Hope it helped
Execute - Based on the batch size and data retrieved in Start method.
If this solves your problem, kindly mark it as the best answer.
Regards,
Magulan
http://www.infallibletechie.com