Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> SQL Question about atomicity and timing of UPDATES

SQL Question about atomicity and timing of UPDATES

From: Greg Stark <greg-spare-1_at_mit.edu>
Date: Tue, 26 Oct 1999 19:38:54 GMT
Message-ID: <87iu3t52ut.fsf@HSE-Montreal-ppp19485.qc.sympatico.ca>

If I have a table tbl with one record:

A B
- -
1 1

and I execute:

UPDATE tbl SET A=B+1, B=2

          A B A B
do I get - - or - - ?

          2 2 3 2

And am I guaranteed to always get that one? I would have expected 2,2 and indeed it usually appears I do. But sometimes I appear to get results that I can only explain if I was getting the equivalent of 3,2.

The actual query in hand is more like

UPDATE tbl SET A=decode(B,2,A+1,1), B=2

and I appear to be getting A incremented even when B=1, and B becomes 2. This only happens under heavy load, when I'm testing it it always seems to work atomically as expected.

--
greg Received on Tue Oct 26 1999 - 14:38:54 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US