function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SamarSSamarS 

Work-around for reordering locked rows?

What will happen if I reorder pro-grammatically records returned by SOQL using FOR UPDATE keyword?
Biswojeet Ray 11Biswojeet Ray 11

Hi @samar

 

Can you please send your SOQL query?

 

Thanks,

Biswojeet Ray 11Biswojeet Ray 11

Hi Samar

FOR UPDATE AFAIK is a "pessimistic" (i.e lock before you do anything) type of locking. So another user that's trying to update the same record might receive an error.

You can specifically lock a set of records in a result set by adding the keywords for an update
to a SOQL query. This approach protects the integrity of your data, but can also cause other
processes to wait until the locking transaction completes, so carefully consider the use of these
options.

 

Please send your query.

Thanks,

SamarSSamarS
@Biswojeet
Query is like 
List<customObject__c> listRecords = [Select ID, Name, Date from customObject__c Order By Date]

Here if you see I have Order By clause in query but it didnt work with FOR UPDATE keyword, but requirement is to keep order intact.

Any idea?