What to do with this situation?

From: (wrong string) ªü´ö Thenardier <Thenardier_at_POBoxes.com>
Date: 1997/10/01
Message-ID: <34327f17.40445566_at_news.netvigator.com>#1/1


[Quoted] [Quoted] I wanna know how Oracle & PL/SQL deals with a situation like this. And how to prevent this?

Suppose there is a row:

ProdID Name Qty
------ --------------- -------
P00001 Product ABC 100

Now 2 users (A & B) are going to read from and update to it.

Time Sequence Users' Action


[Quoted] 1                   A reads.  Screen displays Qty = 100.

2                   B reads.  Screen displays Qty = 100.

3                   A wants to update Qty with Qty = Qty - 50.
                    A locks the table for update.

4                   B wants to update Qty with Qty = Qty - 20
                    B tries to lock the table but fails.

5                   A has successfully updated the row.
                    Now Qty = 50
                    (But B's screen still displays = 100 and
                     B still wants to update Qty = Qty - 20)!!!

6                   B locks the table for update.
                    B updates Qty = Qty - 20. ie 100 - 20.
                    Now Qty = 80 (not 50 anymore)

These could happen within a very short period of time. What's should i do?

Thanx in advance.

Thenard

--
********************************************************

*** ***
*** ¦³°ÝÃD¶Ü¡H Got a problem? ***
*** §äªü´ö§a¡A Just ask Thenardier, ***
*** ¥L·|±N¥¦Åܦ¨¨aÃø¡I he'll make it a tragedy! ***
*** ***
********************************************************
Received on Wed Oct 01 1997 - 00:00:00 CEST

Original text of this message