Em 23/09/08, Marcelo Aldi Vera Olate<[EMAIL PROTECTED]> escreveu:
> Concordo com esta preocupação, pois dependendo da quantidade de usuários
> acessando o DB pode acontecer de o mesmo registro ser acionado por dois ou
> mais clientes/usuários, isto vai dar problemas no futuro, o ideal seria
> realizar a consulta e poder travar aquele registro para edição assim que
> fosse selecionado, não sei como realizar este procedimento mais fica minha
> consideração para os magos do PG...
>


SELECT ... FOR UPDATE?
http://www.postgresql.org/docs/current/interactive/sql-select.html

"FOR UPDATE causes the rows retrieved by the SELECT statement to be
locked as though for update. This prevents them from being modified or
deleted by other transactions until the current transaction ends. That
is, other transactions that attempt UPDATE, DELETE, or SELECT FOR
UPDATE of these rows will be blocked until the current transaction
ends. Also, if an UPDATE, DELETE, or SELECT FOR UPDATE from another
transaction has already locked a selected row or rows, SELECT FOR
UPDATE will wait for the other transaction to complete, and will then
lock and return the updated row (or no row, if the row was deleted)."

Leia também sobre transações.

Osvaldo
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a