Question : Ho to do row level lock of a oracle database table?

Here there are 4 different weblogic servers and trying to select and update one row in oracle 9i database..Here I want to do a row level lock using Hibernate.so that if one jvm has picked others cant update that

This is an urgent requirement please help and guide

Answer : Ho to do row level lock of a oracle database table?

Row level locking is done in oracle using a FOR UPDATE clause.
See the example, where SESSION1 locks the row and SESSION2 attempts a lock, which fails.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
SESSION-1>select * from tbl1;
 
       VAL DT        USR_ID
---------- --------- --------------------
         5 17-DEC-08 TEST
        10 17-DEC-08 TEST
        20 17-DEC-08 TEST
        40 17-DEC-08 TEST
        50 17-DEC-08 TEST
 
SESSION-1>select * from tbl1 where val=5 for update nowait;
 
       VAL DT        USR_ID
---------- --------- --------------------
         5 17-DEC-08 TEST
 
 
*******************************************
 
SESSION-2>select * from tbl1 where val=5 for update nowait;
select * from tbl1 where val=5 for update nowait
*
ERROR at line 1:
ORA-00054: resource busy and acquire with NOWAIT specified
Random Solutions  
 
programming4us programming4us