Re: Row Lock

Поиск
Список
Период
Сортировка
От Dave Tenny
Тема Re: Row Lock
Дата
Msg-id 3F7D7AE4.7090708@comcast.net
обсуждение исходный текст
Ответ на Row Lock  ("Waldomiro" <wmiro@ig.com.br>)
Ответы Re: Row Lock  (Alessandro Polverini <polverini@nibbles.it>)
Список pgsql-jdbc
-- begin transaction
SELECT rowstuff FROM table WHERE record-of-interest = somekey FOR UPDATE
... get new value from the user
UPDATE rowstuff WHERE record-of-interest = somekey
COMMIT

-----------------------

However, it is considered exceedly poor application design to have any interactive
dialogs in the midst of a transaction.  (Really bad, don't do it!  You'll block potentially all users
for potentially unlimited amounts of time).

Suggest you get the row value, remember it, present to the user for update OUTSIDE a transaction,
then start a transaction to update when you have the new value.  If the row value has changed to something incompatible
with the user's value, abort and complain, otherwise do the update.


Waldomiro wrote:
Hello,
 
I have an aplication which ask a code to bring up the data on screen, then the user can change the data and save it.
 
My problem is :
 
2 users at same time can put the same code and make diferent changes.
 
Are there any way to lock this record in postgres when the first user is changing the data on screen ?
 
What shoud I do ?
 
Thanks
 
Waldomiro C Neto.
Shx Informática Ltda.
+55 (11) 5581-1551
www.shx.com.br
wmiro@shx.com.br
 

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: "Waldomiro"
Дата:
Сообщение: Row Lock
Следующее
От: Craig Moon
Дата:
Сообщение: Re: Concurrent Connections - User only allowed one