It doesn't lock the row from being read. I want to make sure the row cannot
be read until I have done my read and updated if necessary. LOCK TABLE does
that but also prevents other rows from being read which is a bit overzealous
for my taste (the app is small so it's probably not a big deal in this case,
but I can see in future possibilities how it would be).
[mailto:pgsql-general-owner(at)postgresql(dot)org]On Behalf Of Doug McNaught
Sent: Monday, December 30, 2002 15:18
To: Andy Kriger
Subject: Re: [GENERAL] lock table question
"Andy Kriger" <akriger(at)greaterthanone(dot)com> writes:
> I have an inventory table. I need to be able to lock a row from being
> read/written while I: check the quantity value; modify it if necessary.
> my experiments, it appears I can only do this with LOCK TABLE. Since this
> locks the whole table and not just the individual row, I'm guessing this
> would create quite a bottleneck if our application were larger. I'm also
> guessing that there's a better way to approach this probably common need.
Does SELECT ... FOR UPDATE not do what you want?
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
In response to
pgsql-general by date
|Next:||From: Tom Lane||Date: 2002-12-30 21:17:08|
|Subject: Re: lock table question |
|Previous:||From: Medi Montaseri||Date: 2002-12-30 20:31:45|
|Subject: Re: pg and transactions|