I am trying to write a code which will query account records and lock them using FOR UPDATE keyword and then I am also triggering another batch which will try tu update same record with some more records of account. But even after using Database.update(xyz,false) I am getting error lock for all other records as well even if we are using Database.update
Can anyone please help me. Below is sample code snippet:
First i am executing below code to lock the specific record:
Account act = [SELECT Id FROM Account WHERE Id = '0010I00002DmyzG' FOR UPDATE];
for (Integer index = 0; index < 44444; index ++ ) {
for (Integer index1= 0; index1 < 44444; index1++ ) {
}
}
Secondly I am executing below code to update the same record used above with two separate records but even if I am using database.update I am getting row lock error for other two records as well
Set<Id> cSet = new Set<Id>();
cSet.add('0010I00002DmyzG');
ctSet.add('0010I00002Dmyv7');
cSet.add('00128000009iR8y');
List<Account> ctrList = new List<Account>();
for (Account ct : [
SELECT Active__c FROM Account WHERE Id IN :cSet]) {
ct.Active__c = 'Yes';
ctrList.add(ct);
}
Thanks