Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

lock table object problem

Former Member
0 Likes
500

Hi all, i have a question of locking object. to lock a table, we use two functions to lock and unlock a table. if i use "insert**" clause to update a table, can the enqueue_** work too? someone told me enqueue_*** can oly lock write access to table while using "update**" clause, but won't work if i use "insert**" clause, i'm not quite sure of that, anyone got the idear?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
469

Its true, when you lock a table, its going to lock the current data. INSERT statement can still insert new rows into the table and that should not affect the existing data, right? Where as UPDATE will affect the existing data so the lock will not allow the updates.

Regards,

Ravi

Note : Please mark all the helpful answers and close the thread if the issue is resolved

4 REPLIES 4
Read only

Former Member
0 Likes
470

Its true, when you lock a table, its going to lock the current data. INSERT statement can still insert new rows into the table and that should not affect the existing data, right? Where as UPDATE will affect the existing data so the lock will not allow the updates.

Regards,

Ravi

Note : Please mark all the helpful answers and close the thread if the issue is resolved

Read only

0 Likes
469

got it, thanks. i thought all write access should be forbidden by that lock object before. but if Person A is inserting a record to table, Person B is reading that table, or Person B is deleting records of that table, there will also be inconsistance, right? in that case, how to solve it?

Message was edited by: legend li

Read only

0 Likes
469

Usually any RDBMS will gaurantee the data as in the current state and it will not be right to lock the table for inserting data if some one else is updating a different row. Its not inconsistency, if some one has read the data 1 second before the new record was inserted. Its a matter of timing. When he refreshes the screen he is going to see the new data.

Regards,

Ravi

Read only

0 Likes
469

i think lock can only work to avoid inconsistance while more than one users are writing to the table:when update or delete, for the two clauses will change the existing entries in table, update will conflict with another update or delete to the same entry, so that is the reason why lock doesn't work while inserting.