I have a big dataset in Oracle which I need to process some of the rows which has a column PROCESSED= 0
.
I have multiple instances of an application which will read 1 row at a time and perform the processing. To avoid multiple threads to access to the same row - I am using
SELECT * FROM FOO WHERE ROWNUM = 1 FOR UPDATE
If I execute the above query, the first thread is locking the row and the other rows are not able to fetch any rows as the ROWUM = 1
is already locked by the first thread. What I am trying to achieve is to fetch the "next unlocked" row.
Is there an efficient way to do it via SQL?