Re: Recommendations For Select for Update Statments

From: Michael Cunningham <napacunningham_at_gmail.com>
Date: Tue, 12 Apr 2016 08:18:28 -0700
Message-ID: <CAPt39turk4nkqo6rXJyV0DpgrBK6CF+Mo_tu4A_YJBymtqNjOA_at_mail.gmail.com>



Hello Walid,

Oracle has something similar to the article mentioned that is built in. Take a look at ORA_ROWSCN. It also does logical locking vs. physical locking.

The ORA_ROWSCN is a pseudo column that will change when a row is updated. The default behavior is it will be the same for all rows in a block. However, if the table is build with 'ROW DEPENDENCIES' is will be unique for every row in the table.

How it works is you would also select the ORA_ROWSCN in your select statement and then use it again in the update. If there were zero rows updated then it is because someone else updated the row before you did.

The bad part for either of these solutions is there would be a fair amount of changes needed to the code to deal with times when the update failed with zero rows.

Michael

On Tue, Apr 12, 2016 at 4:40 AM, Norman Dunbar <oracle_at_dunbar-it.co.uk> wrote:

> This might help. Maybe.
>
> http://qdosmsq.dunbar-it.co.uk/blog/2009/01/lazy-developer-syndrome-and-rowids
> /
>
> Cheers,
> Norm.
> --
> Sent from my Android device with K-9 Mail. Please excuse my brevity.

-- 
Michael Cunningham

--
http://www.freelists.org/webpage/oracle-l
Received on Tue Apr 12 2016 - 17:18:28 CEST

Original text of this message