Consultor Eletrônico



Kbase 6932: does undo, leave but should do undo, retry
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   11/28/2000
does undo, leave but should do undo, retry

910201-SLK01There appears to be some confusion as to the behavior of UNDO, RETRY
in certain blocks under particular circumstances. There are
times when rather than doing the default behavior of UNDO, RETRY
PROGRESS will take UNDO, LEAVE instead. This is not a bug, it is a
feature of PROGRESS' infinite loop protection as described in the
APS Course. For example:
MAIN:
REPEAT:
FIND FIRST CUSTOMER EXCLUSIVE-LOCK NO-ERROR NO-WAIT.
IF LOCKED CUSTOMER OR NOT AVAILABLE CUSTOMER THEN
UNDO MAIN, RETRY MAIN.
PAUSE MESSAGE "WE HAVE EXCLUSIVE-LOCKED THE CUSTOMER RECORD".
UPDATE CUSTOMER.
END.
PAUSE MESSAGE "EXECUTING OUTSIDE OF THE REPEAT LOOP".

This example, run in multi-user with two users running the same
code, would read the first customer record and allow operator
to update the customer information. If the program finds the
customer record LOCKED it issues an UNDO, RETRY and attempts to
read the customer record again. This process continues until
the record is finally free and available to be read.

The rules of error processing, say that each time through, PROGRESS
will undo the main block and retry it. However, since PROGRESS
sees that there will be no change in the next iteration, rather than
going into an infinite loop, it will protect the user, and take
UNDO, LEAVE (on a repeat or do block -- if this had been a for each
block, PROGRESS would translate that to UNDO, NEXT for infinite
loop protection). Explicit error processing stated on the blocks
will not change this (e.g., REPEAT ON ERROR UNDO, RETRY ON ENDKEY
UNDO, RETRY).

How can you override this protection? One way is to put some user
interaction before the IF LOCKED test (which would be true
through each iteration), as in these two cases:
REPEAT:
FIND FIRST CUSTOMER...
PAUSE.
...
END.


The RETRY function used inside the block will also override infinite
loop protection:
REPEAT:
IF RETRY THEN MESSAGE "retrying the block".
FIND FIRST CUSTOMER...
...
END.

Progress Software Technical Support Note # 6932