I have a batch which stores some information in stateful variable. My question is whether that variable will retain the value in next 'execute' if governor limit occurred in current 'execute'? Consider below code.
global class MyBatch implements Database.Batchable<sObject>, Database.stateful{
integer stateFullCount = 0;
global void execute(Database.BatchableContext bc, List<Account> scope){
stateFullCount++;
system.debug( stateFullCount );
if(stateFullCount == 2){
//Dummy governor limit SOQL rows:510000
list<account> lstAccount = [select id from account limit 51000]; }
}
}
If we dry run above code, what will be value for stateFullCount?
1st Execute: debug shows -> stateFullCount as 1;
2st Execute: debug shows -> stateFullCount as 2; //governor limit occurs.
3st Execute: debug shows -> stateFullCount as ?; ( here it will be 2 or 3? if 2 then how to achieve it to retain the value as 3?)