Progress OpenEdge
Member
Qn 15: Is the following code correct? Explain! Assume that Sports2000 database is connected!
DEFINE VARIABLE order-rec AS ROWID.
DEFINE VARIABLE answer AS LOGICAL.
REPEAT:
FIND NEXT order NO-LOCK.
DISPLAY order WITH 2 COLUMNS 1 DOWN.
MESSAGE "Do you want to update this record?"
VIEW-AS ALERT-BOX QUESTION BUTTONS YES-NO UPDATE answer.
IF answer THEN DO:
order-rec = ROWID(order).
UPDATE order EXCEPT order-num cust-num.
END.
END.
Ans: Two issues.
1. There is no error-handling in the find.
2. before the update the record is not fetched in exclusive-lock
Qn 16: If necessary, fix the code in Question15.
Ans:
DEFINE VARIABLE order-rec AS ROWID.
DEFINE VARIABLE answer AS LOGICAL.
REPEAT:
FIND NEXT order NO-LOCK NO-ERROR.
IF AVAILABLE order THEN DO:
DISPLAY order WITH 2 COLUMNS 1 DOWN.
MESSAGE "Do you want to update this record?"
VIEW-AS ALERT-BOX QUESTION BUTTONS YES-NO UPDATE answer.
IF answer THEN DO:
order-rec = ROWID(order).
FIND order WHERE ROWID(order) = order-rec EXCLUSIVE-LOCK NO-ERROR.
IF AVIALABLE order THEN
UPDATE order EXCEPT order-num cust-num.
END. /* If answer */
END. /* If Avail Order */
END. /* Repeat */
DEFINE VARIABLE order-rec AS ROWID.
DEFINE VARIABLE answer AS LOGICAL.
REPEAT:
FIND NEXT order NO-LOCK.
DISPLAY order WITH 2 COLUMNS 1 DOWN.
MESSAGE "Do you want to update this record?"
VIEW-AS ALERT-BOX QUESTION BUTTONS YES-NO UPDATE answer.
IF answer THEN DO:
order-rec = ROWID(order).
UPDATE order EXCEPT order-num cust-num.
END.
END.
Ans: Two issues.
1. There is no error-handling in the find.
2. before the update the record is not fetched in exclusive-lock
Qn 16: If necessary, fix the code in Question15.
Ans:
DEFINE VARIABLE order-rec AS ROWID.
DEFINE VARIABLE answer AS LOGICAL.
REPEAT:
FIND NEXT order NO-LOCK NO-ERROR.
IF AVAILABLE order THEN DO:
DISPLAY order WITH 2 COLUMNS 1 DOWN.
MESSAGE "Do you want to update this record?"
VIEW-AS ALERT-BOX QUESTION BUTTONS YES-NO UPDATE answer.
IF answer THEN DO:
order-rec = ROWID(order).
FIND order WHERE ROWID(order) = order-rec EXCLUSIVE-LOCK NO-ERROR.
IF AVIALABLE order THEN
UPDATE order EXCEPT order-num cust-num.
END. /* If answer */
END. /* If Avail Order */
END. /* Repeat */
Last edited: