I need to update a row in an Oracle database so that I do not hide changes from another client in my web application.
On my current system, I do the following:
SELECT * FROM table WHERE id=:ID AND lastmodified=:LASTMOD
if the row still exists with the same last modified date when we started, we know that no one changed it, so we can update it using the last modified time.
However, when you do this manually using two sessions, I noticed that if two clients select at about the same time, you can skip it, that the line has been changed between the selection and update stages due to the fact that they occur in for the same second or millisecond.
The end result is that I am compressing the changes of another user and not warning about its occurrence.
I was thinking about using SELECT FROM UPDATE, but it seems like a bad idea (especially for web applications), the article recommends re-reading (this is what I am doing above), but I still think I'm in danger of a race.
Edit: I realized I was worried about how time refers.
source share