Programming Issues - EXCLUSIVE Lock

Chris Kelleher

Administrator
Staff member
Hi all,

Can anyone tell me why this program is only allowed one user running at a time?
Does the exclusive-lock apply to a paticular record only or the whole table?
For example, if I enter wo_nbr = "123", another user trying to run the same
program with wo_nbr "345".
It will display "ca_mstr in user by another user....".
I think I should be still able to update a different record.

<BLOCKQUOTE><font size="1" face="Arial, Verdana">code:</font><HR><pre>
mainloop:
repeat:
update wo_nbr with frame a.

find ca_mstr where ca_po_nbr = wo_nbr exclusive-lock no-error.
if not available ca_mstr then do:
bell.
message "Wo number " + wo_nbr + " does not exist".
undo mainloop, retry mainloop.
end.
update ca__chr01 ca__chr02 with frame a.
end.
[/code]

Thanks

Lisa
 

Chris Kelleher

Administrator
Staff member
I believe the issue is that ca_po_nbr is not indexed. So the first problem
is that you should be using a FIND FIRST instead of just FIND. The reason
you are getting other records locked is also due to the fact it is not
indexed. Progress is having to grab a group of records to find the one you
have asked for and it puts an exclusive lock on each group of records that
it retrieves. So the next user has to get the same group of records to find
the one that they are looking for, but the first user already has an
exclusive lock on all of the records in that group.

You should probably try something like:

<BLOCKQUOTE><font size="1" face="Arial, Verdana">code:</font><HR><pre>

DEF BUFFER camstr FOR ca_mstr.
FIND FIRST ca_mstr WHERE ca_po_nbr = wo_nbr NO-LOCK NO-ERROR.
IF AVAIL ca_mstr THEN
DO:
FIND camstr WHERE RECID(camstr) = RECID(ca_mstr) EXCLUSIVE.
/* continue your processing using the buffer. */
END.
ELSE
DO:
bell.
message "Wo number " + wo_nbr + " does not exist".
undo mainloop, retry mainloop.
END.
[/code]

--
James Blankenship

United Systems, Inc. http://www.usiatl.com
Phone: 207-885-9902
Fax: 207-885-9903
Mobile: 207-450-8577
jlb@usiatl.com
 

Chris Kelleher

Administrator
Staff member
your FIND is looking through records sequentially on the primary key. The
previous FIND of "123" still has that record locked when you look for "345".
One way around this is to FIND with NO-LOCK. DISPLAY the found record, allow
changes, then FIND with a EXCLUSIVE-LOCK when you do the ASSIGN.

Charlie Stine, CPA, MBA
Senior Consultant
Protech Systems
cstine@pilot.infi.net
 

Chris Kelleher

Administrator
Staff member
Hi all,

Thank you very much for your advice espcially James Blankenship, Charlie Stine
Charles T.Simpson and Neil Yeung.

I am using the ca_nbr field instead of the ca_po_nbr now.
It's indexed and more effecient this way.

Regards,

Lisa
 
Top