Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6927359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:02:39+00:00 2026-05-27T11:02:39+00:00

I need to update a row in an Oracle database in a way that

  • 0

I need to update a row in an Oracle database in a way that I don’t silently clobber the changes from another client in my web based application.

In my current system I perform 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 nobody has changed it so we can update using the last modified time.

However when doing this manually using two sessions I noticed if two clients select at roughly the same time its possible for one to miss that the row has been changed between the select and update step due to both occurring within the same second or millisecond.

The end result is that I clobber the changes of the other user and there is no warning that it occurred.

I was thinking of using SELECT FROM UPDATE but apparently that’s a bad idea (especially for web apps), the article recommends re-reading (which is what I’m doing above) but I still think I’m at risk of a race condition.

Edit: Made it clear I was concerned about the way time is referenced.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:02:39+00:00Added an answer on May 27, 2026 at 11:02 am

    I’m assuming that your UPDATE statement itself is verifying the lastmodified value that you read in your SELECT statement as ninesided suggests.

    If lastmodified is a DATE, then there is a potential race condition if there are multiple updates to the same row in the same second since a DATE only has granularity to the second. If lastmodified is a TIMESTAMP, on the other hand, the window in which the race condition can occur is much more limited since a TIMESTAMP will have between 3 and 9 digits of sub-second precision (3 on most Windows machines, 6 on most Unix machines). It’s pretty unlikely though not impossible that you’d have two updates at the same millisecond or even the same microsecond. But it’s not infallible.

    You can use a sequence-generated value instead of a last modified date. That can guarantee that you won’t lose an update since a NOCYCLE sequence won’t return the same value twice. But if you go down that path, you’re either losing the information benefit of having a last update date on every row or you’re storing a few extra bytes of data in every row of the table. Either of those trade-offs may be worth it depending on your application or either might create more problems than it resolves.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to update a row in a table, and get a column value
I need to update a row with a formula based on the largest value
I need to update a certain row in table, already did validators to assure
I need to update each row of a table with one column as sum
I have a program that connects to an Oracle database and performs operations on
I need to update a row of alarms with Linq to SQL, which can
I have a simple question here. I need to UPDATE a row table by
I have a list of divs (div.row), which I need to update the background-color
I have a mysql table with a row called log. I need to update
I need to make an sql query which tries to update a row by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.