Valid PDII Dumps shared by ExamDiscuss.com for Helping Passing PDII Exam! ExamDiscuss.com now offer the newest PDII exam dumps, the ExamDiscuss.com PDII exam questions have been updated and answers have been corrected get the newest ExamDiscuss.com PDII dumps with Test Engine here:
Access PDII Dumps Premium Version
(204 Q&As Dumps, 35%OFF Special Discount Code: freecram)
Recent Comments (The most recent comments are at the top.)
Ans is b Use "FOR UPDATE" in a soql query
Account acc = [SELECT Id, Is_Registered__c FROM Account WHERE Id = :accountId FOR UPDATE];
if (!acc.Is_Registered__c) {
acc.Is_Registered__c = true;
// ...set other fields...
update acc;
}
Using 'FOR UPDATE' in your SOQL query will place a row-level lock on the queried Account record. This ensures that:
No other transaction can modify that record until your transaction completes.
It prevents race conditions where two users could read the same unregistered Account and both proceed to update it simultaneously.
Database.update(account, false) --> false suppresses errors for partial updates but does not prevent record collision or overwrites.
Add a try/catch block --> Useful for handling errors after they occur, but does not prevent concurrent modification.
Use upsert instead of update --> upsert is used to insert or update based on record existence — not useful for handling concurrent updates to existing records.
It should be B.
B is correct.
"In Apex, you can use FOR UPDATE to lock sObject records while they’re being updated in order to prevent race conditions and other thread safety problems."
Ref: https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_for_update.htm
B should be the correct answer.