Concurrent access, lock the database table?

Posted by soonhuat_81 on 19-Aug-2014 22:53

Hi Folks,


How to lock down a DB record instead of theentire DB table to prevent concurrent update to the data ?

Previously, i use the progress version 9.1B there are allow to lock down the entire DB table.

Any advise?

Thank you!

All Replies

Posted by soonhuat_81 on 20-Aug-2014 00:48

E.g select * from tblUser  , it will lock the entire table.

select * from tblUser where userID = "abc".

How to lock the only this record instead of the entire table ?

Posted by Thomas Mercer-Hursh on 20-Aug-2014 09:29

You are doing this in SQL rather than ABL?  

Posted by soonhuat_81 on 20-Aug-2014 19:56

in ABL, how to go about it to lock only the individual record?

Thanks.

Posted by Dileep Dasa on 21-Aug-2014 00:35

In ABL, you can use SHARE-LOCK or EXCLUSIVE-LOCK for this purpose. Please refer to the documentation of these options.

Posted by Brian K. Maher on 21-Aug-2014 07:36

 
FIND FIRST SomeTable EXCLUSIVE-LOCK NO-WAIT NO-ERROR.
 
IF AVAILABLE SomeTable THEN
    /* Hey, I Locked The Record */
ELSE
    DISPLAY ERROR-STATUS:GET-MESSAGE(1) FORMAT "X(80)".

Posted by Thomas Mercer-Hursh on 21-Aug-2014 09:06

In ABL, you can't do anything other than lock an individual record ... with one exception.   I don't know if this is still true, but it used to be the case that if you did a FOR EACH EXCLUSIVE-LOCK with a WHERE clause that eliminated large numbers of records, it would lock all the records it skipped while it looked for one that qualified.  This was ***many*** years ago and I never see it any more since I would always do the outer loop no-lock and then reread the selected record exclusive lock.

I suspect there must be something behind this question that you haven't told us, so perhaps it would help if you explained a bit more.

Posted by gus on 21-Aug-2014 09:16

also, there is no UNLOCK statement. Locks are managed internally by the 4GL compiler, 4GL runtime, and the database based on things like buffer scope and transaction boundaries which are used to determine the duration of row-level locks.

in SQL, locks are managed by the OpenEdge SQL Server's query engine, primarily based on the isolation level in effect and transaction duration.

This thread is closed