You need to sign in to do that
Don't have an account?
vijay kumar k
how to write the execute method will run at finish method in bathch class
i want to know how many times the execute method will run , so it is poossible to know using finish method.i mean after execute the batch class ,finnally i want see how many times my execute method will run. please give me simple example
How many times execute method will run it totally depends on the Batch Size and number of the Records retrieved in start method.
database.executeBatch(yourClassInstance, batchSize).
Here,Default batch size is 200 i.e. execute method will process 200 records at a time. If your start method returns 1000 records then execute method will run 5 times.
You can use a Integer variable that will count how many times execute method will run. Here is the simple example of batch class.
You can run this batch class from Anonymous window by executing this code--
database.executeBatch(new AccounBatch(),1);
Mark this answer as solved if it helps you and let me know for further query
Regards
Sandeep
coming to your point, If your start method returns 1000 records then execute method will run 5 times.ok ,i want that anser at finish method. i mean how to show that number(5 as a answer ,it is every one knows) in system.debug(). please help me to programatically your execute method will run '5' times.
For getting result of i into finish method you have to retain value of i. For this you have to implement Dtatbase.stateful Interface.
In finish method you can debug i.
Hope its help you.
Regards
Sandeep