Originally posted by Jeanne Boyarsky:
I don't think SELECT FOR UPDATE will work here. You only get the update lock until the end of a transaction. While the user is looking at the web page, there isn't a lock. Otherwise, the user could go away and leave your data locked forever.
Another alternative is to add a column to the table with the time that you showed the sale item to a user. If there is a timestamp in this field, don't show it to the next user. (The timestamp is so you can periodically clean up the database with users who abandoned the page.)
As mentioned over on the Sun forum where the same question was posted, both an additional column and the use of either SERIALIZABLE transactions or SELECT FOR UPDATE are required, otherwise a concurrent SELECT on a READ_COMMITTED transaction can hand out the same rows to 2 or more users.
The OP then asked for code, which I don't have time to supply...