Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Best way to Lock a Table in exclusive mode ?

591226Aug 2 2007 — edited Aug 6 2007
Hi
I have a procedure that update a record in a table. This table is accessed for many work stations and these stations update this table several times. In average this table is updated 900,000 times a day. My oracle version is 9.02
In this table there are no deletes.
The records that are in this table are inserted by other process that is working ok.


My procedure do this:

Receive some parameters ( param1 , param2, param3)
...
IF condition = true THEN
LOCK TABLE my_table IN EXCLUSIVE MODE;

SELECT my_table_id INTO v_my_table_id FROM my_table WHERE available = 'Y' AND rownum = 1;

Update my_table set SET my_date = sysdate, my_field1 = param1, available = 'N' WHERE my_table_id = v_my_table_id;

COMMIT;

..........

The problem here is that some times this process is very slow , and the lock in the table remains for a long time and suddenly the table is released.
I review the CPU of the server whereis the database; and is normal.
This process has been working for 2 years and now is failing.

Could you help me to know if there is a better way to do this process?

I can't undesrtand why this behaivor, if is a simple transaction.

I really appreciate your help

Lorein
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 3 2007
Added on Aug 2 2007
12 comments
2,214 views