DO FOR updOrder-line TRANSACTION

bienphong

New Member
DO FOR updOrder-line TRANSACTION:
FIND updOrder-line WHERE ROWID(updOrder-line) = ROWID(order-line) EXCLUSIVE-LOCK NO-ERROR.
updOrder-line.qty = updOrder-line.qty + 5.
END.
DO FOR updItem TRANSACTION:
FIND updITEM WHERE updITEM.item-num = order-line.item-num EXCLUSIVE-LOCK NO-ERROR.
updITEM.allocated = updITEM.allocated - 5.
END.
 

Cringer

ProgressTalk.com Moderator
Staff member
Do you have a question, or are you just posting random code snippets?
 

TomBascom

Curmudgeon
In the absence of an actual question I do have a comment to share ;)

Generally speaking... in real code you should not suppress errors with NO-ERROR and then fail to test for and handle those errors that you are ignoring. A point that I probably forget to mention often enough when I share snippets as above.

For instance, in the code above, it is possible that someone in another session deleted the record in the period between whenever "order-line" was found (presumably with NO-LOCK) and when you get around to EXCLUSIVE-LOCK ing it.
 

RealHeavyDude

Well-Known Member
This is just a test ...
... probably whether we qualify ;)
 

andre42

Member
I don't think it makes much sense to do a code review of this snippet.
If I had to I would start with the fact that this should be done in a single transaction, not two separate transactions.
 
Top