Title: RE: Hmmmmm

I just had another idea.  Maybe you can use UPDATE <table> SET <column>=<column>+1 RETURNING <column> INTO <somevariable> instead of the SELECT FOR UPDATE.  This will add 1 to the current value and return the result to the caller.

Tony Aponte

-----Original Message-----
From: Aponte, Tony
Sent: Friday, January 25, 2002 11:11 AM
To: '[EMAIL PROTECTED]'
Cc: '[EMAIL PROTECTED]'
Subject: RE: Hmmmmm


What you are observing is the concurrency mechanism as implemented in the Oracle rdbms.  I couldn't explain it better in an email so I suggest you get a hold of Expert One-on-one Oracle by Thomas Kyte, chapter 3 on Locking and Concurrency.  Another thought I have is that it looks like you are trying to implement a sequence number.  If the application can tolerate gaps in the numbers then you can use an rdbms-managed sequence number and use NEXTVAL in place of the SELECT FOR UPDATE.

HTH.
Tony Aponte

-----Original Message-----
From: Stefan Jakobsson [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 25, 2002 5:35 AM
To: Multiple recipients of list ORACLE-L
Subject: Hmmmmm


Having a small problem I need some help with...

The problem is trying to lock a row on a parameter table for an application.

The thing we need to do is following:

Read the value in one row. LOCK that row for other users, increase the value
with one
update the row with the new value and release if for access to other users.

We are trying to use the following SQL statement.

SELECT medlnr FROM parametrar FOR UPDATE OF medlnr NOWAIT;

But the thing is that when we try, anyone can head on in and select the same
value
and even make an update of that row...

What am I missing here?

Regards,
Stefan Jakobsson
Programmer
Arel-Data
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Stefan Jakobsson
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to