Caro Elcio:

  Há um lock implícito após o comando update (DML), conforme especificado em 
http://download.oracle.com/docs/cd/B10501_01/server.920/a96524/c21cnsis.htm#3017:



Default Locking for INSERT, UPDATE, DELETE, and SELECT ... FOR UPDATE 
The locking characteristics of INSERT, UPDATE, DELETE, and SELECT ... FOR 
UPDATE 
statements are as follows:
        * The transaction that  contains a DML statement acquires exclusive row 
locks 
on the rows  modified by the statement. Other transactions cannot update or 
delete  the locked rows until the locking transaction either commits or rolls  
back.
        * The transaction that  contains a DML statement does not need to 
acquire row 
locks on any rows  selected by a subquery or an implicit query, such as a query 
in a WHERE clause. A subquery or implicit query in a DML statement is 
guaranteed  
to be consistent as of the start of the query and does not see the  effects of 
the DML statement it is part of.
        * A query in a transaction  can see the changes made by previous DML 
statements 
in the same  transaction, but cannot see the changes of other transactions 
begun  
after its own transaction.
        * In addition to the  necessary exclusive row locks, a transaction that 
contains a DML  statement acquires at least a row exclusive table lock on the 
table that  contains the affected rows. If the containing transaction already 
holds  a share, share row exclusive, or exclusive table lock for that table,  
the row exclusive table lock is not acquired. If the containing  transaction 
already holds a row share table lock, Oracle automatically  converts this lock 
to a row exclusive table lock. 

  

  Então, se você quer bloquear um registro PELO BANCO, é só dar um update na 
linha especificada, que tal será bloqueada, até que haja um COMMIT ou ROLLBACK.

Atenciosamente,

Márcio de Figueiredo Moura e Castro







________________________________
De: Elcio Francisco <elciofranci...@yahoo.com.br>
Para: oracle_br@yahoogrupos.com.br
Enviadas: Sexta-feira, 25 de Março de 2011 17:20:24
Assunto: [oracle_br] lock na tabela

  
Pessoal, tenho uma tela onde traz uma lista com varios registros. O usuario 
precisa editar o registro e atualizar alguns dados.Porem varios usuarios tem 
acesso a essa lista. Gostaria de saber se alguem sabe como bloquear o registro 
para ousuario que selecionou a linha, caso outro usuario queira selecionar a 
mesma linha o sistema gerar uma mensagemtipo 'Registro ja em uso para Outro 
Usuario'.
Versão do Banco : ORACLE 10Tela desenvolvida no PL/SQL WEB
Obrigado
Elcio Francisco 
Analista de Sistemas 

[As partes desta mensagem que não continham texto foram removidas]


 

[As partes desta mensagem que não continham texto foram removidas]

Responder a