...
...
IF AVAIL customer THEN
IF NOT LOCKED DO
:
END.
...
...
I try with NO-LOCK and EXCLUSIVE-LOCK NO-WAIT, but this part of tree never be executed.
This is what the online-docs do say about LOCKED:
LOCKED function
Returns a TRUE value if a record is not available to a prior FIND . . . NO-WAIT statement because another user has locked a record.
So this will work (in case another user has locked the record):
FIND FIRST Customer EXCLUSIVE-LOCK NO-WAIT NO-ERROR.
IF NOT AVAILABLE Customer THEN IF LOCKED Customer THEN
END.
/
This is the best practise that i can think ... */
/* Inizio del tipico codice per un blocco transizionale */
FIND nome_tabella USING nome_tabella.nome_campo NO-LOCK NO-ERROR.
IF AVAILABLE nome_tabella THEN DO:
label_transazione:
DO TRANSACTION:
FIND CURRENT nome_tabella EXCLUSIVE-LOCK NO-WAIT NO-ERROR.
IF AVAILABLE nome_tabella THEN DO:
IF NOT CURRENT-CHANGED nome_tabella THEN DO:
DELETE nome_tabella.
MESSAGE "Record cancellato correttamente sotto transazione!".
END.
ELSE DO:
MESSAGE "Il record é cambiato nel tempo!".
END.
END.
ELSE DO:
IF LOCKED nome_tabella THEN DO:
MESSAGE "Il record non é disponibile perché bloccato!".
UNDO label_transazione, RETRY label_transazione.
END.
ELSE DO:
MESSAGE "Il record non é disponibile e non é bloccato, quindi
probabilmente é stato cancellato nel tempo!"
END.
END.
END. /* ... dell transazione ovviamente! */
END.
ELSE DO:
MESSAGE "Il record non é stato trovato!".
END.
/* Fine del tipico codice per un blocco transizionale */