Kbase P16550: What is the expected behaviour of FIND PREV / FIND NEXT afte
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/03/2003 |
|
Status: Unverified
GOAL:
What is the expected behavior of FIND PREV / FIND NEXT ?
GOAL:
Common questions regarding the behavior of FIND PREV / FIND NEXT.
GOAL:
Frequently Asked Questions regarding the behavior of FIND PREV / FIND NEXT.
FIX:
The following are commonly asked questions. They are written in Question/Answer order.
Q: Why is there no error message if FIND PREV or FIND NEXT fails to find a record ?
A: If a FIND PREV or FIND NEXT operation fails, no error messages are generated, although the error status is raised. This is expected behavior and this "silent" error was implemented to allow gracefully leaving of (nested) loops without requiring self-written error handling.
Q: Why does my loop abort if a FIND PREV or FIND NEXT fails ?
A: This is due to the fact that the END-KEY event is raised as part of the default error handling for the FIND PREV / FIND NEXT statement. Progress will react to this as defined in the ON END-KEY phrase of the statement that started the loop. If no ON END-KEY phrase was defined, the Progress default action of UNDO, LEAVE will occur.
Since the END-KEY event is part of the error-handling, it can be avoided by executing the FIND statement with NO-ERROR. If you do, keep in mind to code your own error-handling.
Q: What record should be returned by a FIND PREV or FIND NEXT if there is no record in the buffer ?
A: This depends on where the cursor indicator on the buffer is located in the record set. The record set is the entire table, unless a record set was PRESELECTed for the current block.
1. If no FIND has been done for the buffer, FIND PREV and FIND NEXT act like FIND LAST and FIND FIRST respectively.
2. If the cursor-indicator is before the first record in the record set, FIND PREV will return no record, and FIND NEXT will act as FIND FIRST.
3. If the cursor-indicator is after the last record in the record set, FIND PREV will act as FIND LAST, and FIND NEXT will return no record.
4. If the cursor-indicator is somewhere in the record set, FIND PREV will find the record before the current position of the cursor indicator, and FIND NEXT will find the record after that position.
Examples, using a Sports database from which customer with cust-num 5 has been deleted:
1. No find statement.
- FIND PREV Customer. DISPLAY Cust-num. -> Returns cust-num = 84
- FIND NEXT Customer. DISPLAY Cust-num. -> Returns cust-num = 1
2. FIND Customer WHERE cust-num = 0 NO-ERROR. followed by:
- FIND PREV Customer. DISPLAY Cust-num. -> Returns nothing
- FIND NEXT Customer. DISPLAY Cust-num. -> Returns cust-num = 1
3. FIND Customer WHERE cust-num = 99999 NO-ERROR. followed by:
- FIND PREV Customer. DISPLAY Cust-num. -> Returns cust-num = 84
- FIND NEXT Customer. DISPLAY Cust-num. -> Returns nothing
4. FIND Customer WHERE cust-num = 5 NO-ERROR. followed by:
- FIND PREV Customer. DISPLAY Cust-num. -> Returns cust-num = 4
- FIND NEXT Customer. DISPLAY Cust-num. -> Returns cust-num = 6