以下のコード スニペットを参照してください。

Credit_Memo__c というカスタム オブジェクトが Salesforce 環境に存在します。このタイプのレコードを取得して操作する新機能開発の一環として、開発者は、Apex トランザクション内でレコードのセットが変更されるときに競合状態が確実に防止されるようにする必要があります。
前述の Apex コードで、開発者はクエリステートメントを変更して SOQL 機能を使用し、トランザクション内の競合状態を防ぐにはどうすればよいでしょうか?
正解:A
To prevent race conditions during an Apex transaction, the SOQL query can be modified to include the "FOR UPDATE" keyword. This keyword locks the records that are returned by the query, preventing other transactions from modifying them until the current transaction is complete. This ensures that the retrieved records cannot be changed by another process before the current transaction is completed, thus preventing race conditions. The correct option to use in the code snippet provided is:
[SELECT Id, Name, Amount__c FROM Credit_Memo__c WHERE Customer_Id__c = :customerId LIMIT
50 FOR UPDATE]
This will lock up to 50 records of Credit_Memo__c with the specified Customer_Id__c for the duration of the transaction.
References:
FOR UPDATE
Preventing Record Update Conflicts