You need to sign in to do that
Don't have an account?
Paras Jain
Why Static variables loose their state in batch class during every execution
why static variables loose their state in batch class during every execution.
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
May I suggest you to please check with below link which might help you with above question.
- http://salesforce.stackexchange.com/questions/70723/why-does-the-value-of-static-variables-in-batch-context-reset-for-each-transacti
Please let us know if anything else is required.Regards,
Nagendra.
Not only static variable ,every variable will lose their state in the batch class why because once the batch is completed all the values will be initialised to null that is how the excuetion happening in the salesforce for my understanding .If you want to maintain the state in the batch class you need to use Database.stateful
Thank you
By default salesforce excuete the batch class like this from my understanding because it it will not initialise to null there is chance to exist previous data then the batch class will fail.
if you will not initialise to null
Let us assume you have excueted the batch with 200 records by five batches after excuetion of one batch list having 200 records again if we excuete the batch next two hunderd records will add to batch then list will be having 400records then the batch class can not excuete four hundered records at the the same then batch will fail like that there is a chance to happen like that
Thanks
By default salesforce excuete the batch class like this from my understanding because it it will not initialise to null there is chance to exist previous data then the batch class will fail.
if Salesforce not initialise to null
Let us assume you have excueted the batch with 200 records by five batches after excuetion of one batch list having 200 records again if we excuete the batch next two hunderd records will add to batch then list will be having 400records then the batch class can not excuete four hundered records at the the same then batch will fail like that there is a chance to happen like that
Thanks