Replace the default lock in Progress mode instead of Lock Beat
You can change it for each individual request (FIND, FOR EACH, etc.) by adding the blocking status to the request using the [NO | EXCLUSIVE | SHARE] -LOCK. If you leave that, you get the default SHARE-LOCK.
You can also compile your code in a session started with the -NL option, which changes the default for that r-code to NO-LOCK.
source to share
If I understand correctly, Progress 4GL NO-LOCK is similar to TSQL WITH (NOLOCK) command. The idea is that you want to write as many records as quickly as possible, and you want to avoid the resource conflict that SHARE-LOCK can create on records that you are not going to edit anyway. Now in TSQL, you are warning that changes that occur as you execute a TSQL query may be overlooked; I'm not sure if this applies to Progress 4GL / ABL. My introduction to Progress 9 and OpenEdge 10/11. Progress of the experts, please correct me if I am too far from here. I'm still a bit new to this.
In FOR-EACH, do this before the keywords BREAK
or BY
(the keyword is BY
similar order
in SQL), but after the sentence where
:
FOR EACH TableName
WHERE TableName.x > 10
AND TableName.y
NO-LOCK BREAK BY TableName.x:
/* Do Code */
END.
IF FOR-EACH is used with the optional EACH / FIRST / LAST query (Assuming MailSubscription Subscription / sub-table), you can set the level for each subquery. In this example, I need to trawl through the subscription records, search for related MailSubscription records, and edit the final, un-enddated, leaving everyone else while working on it, but leaving the main sub-task open for others to edit.
FOR EACH Subscription
WHERE ProductID = 'DB'
AND Subscriber
AND GetsPaper
NO-LOCK,
LAST MailSubscription OF Subscription
WHERE MailSubscription.EndDate = ?
EXCLUSIVE-LOCK
BREAK BY Subscription.SubscriptionID:
/* Fix broken MailSubscription records */
END.
In FIND-FIRST / FIND-LAST, do this after where and before NO-ERROR (assuming you are using IF-AVAILABLE). Remember if you need to capture two different records from the same table in order to define a buffer for at least one of them.
FIND FIRST TableName WHERE TableName.x > 10 AND TableName.y NO-LOCK NO-ERROR.
IF AVAILABLE TableName THEN DO:
/* Do Code */
END.
You can also replace NO-LOCK
with an EXCLUSIVE-LOCK
interchangeable. I should probably have thrown a quote about big power / big responsibility, but if you have access to a progress editor, you probably already got it from your admin. Be safe.
I recommend online backups if you have a fairly new version of Progress. The Internet in the sense of a DB is not taken off for online backup, not for a cloud backup or something else.
source to share