It had been the case that a find inside a for each loop on the same buffer (even a find current) was not allowed. I just tested in OE12 and it is now allowed (at least for a find current). Did this test against the Sports2020 db:
for each customer no-lock
by customer.CustNum:
if customer.CustNum < 3030 then
do:
customer.CustNum = customer.CustNum + 10000.
display customer.CustNum customer.name.
end.
else
leave.
end.
And it compiles and runs correctly. When did this change? Even the OE12 docs still say this is not allowed.
ABL does not allow a FIND statement within a FOR EACH block unless you specify a different table than
the one referenced in the FOR EACH block. When you attempt to compile the following example, ABL
returns the error message "FIND cannot be processed for a FOR EACH mode record":
FOR EACH Customer NO-LOCK:
FIND CURRENT Customer.
END.
I don't see the FIND
Sorry, the code should have read:
for each customer no-lock
by customer.CustNum:
if customer.CustNum < 3030 then
do:
find current customer exclusive-lock.
customer.CustNum = customer.CustNum + 10000.
display customer.CustNum customer.name.
end.
else
leave.
end.
I've used such trick for years to avoid locking lots of records...
FIND CURRENT is allowed on a FOR EACH (on the same record) to upgrade/change the locking status of the record, at least since V8 that I know....
It seems is new from 11.4.0: https://knowledgebase.progress.com/articles/Article/FIND-CURRENT-within-FOR-EACH-fails-to-compile
What is the transaction scope when you re-find with EXCLUSIVE-LOCK? Are all the records found in one transaction or just the record in current iteration?
It is only the record that is currently in the buffer whose lock status is changed when you use FIND CURRENT EXCLUSIVE-LOCK.
It is only the record that is currently in the buffer whose lock status is changed when you use FIND CURRENT EXCLUSIVE-LOCK.
Another question. What happens in this example when the EXCLUSIVE-LOCK fails, because of a lock wait time out?
FOR EACH Customer NO-LOCK:
FIND CURRENT Customer EXCLUSIVE-LOCK.
END.
Is this construct valid? Will Customer be available after a lock wait time out?
FOR EACH Customer NO-LOCK:
FIND CURRENT Customer EXCLUSIVE-LOCK NO-WAIT NO-ERROR.
IF AVAILABLE Customer THEN
....
END.
lock wait timeout generates a stop condition (same as if you type ctrl-c (or ctrl-break)
Yes, but it won't generate stop if you use NO-WAIT NO-ERROR.
The buffer is still available. You just won't have the lock.
This is easy to test yourself :-).
Yes, but it won't generate stop if you use NO-WAIT NO-ERROR.
The buffer is still available. You just won't have the lock.
This is easy to test yourself :-).
> On Jun 10, 2019, at 2:58 PM, Laura Stern wrote:
>
> This is easy to test yourself :-).
>
>
>
what !
you think i should test myself?
sigh. you are correct. i am lazy scum.