ADELIA |
VADELIA |
SADELIA |
WADELIA |
MADELIA |
(I/B) |
(I/B) (S) |
(B) (S) |
(I/B) (S) |
(I) (S) |
Section for use
All
Syntax
READ_PREVIOUS ViewName Option Parameter
Option |
Þ |
*UNLCK | None |
|
|
|
Parameter |
Þ |
*NO_MR | *MR | None |
Description
This instruction involves the reading of the previous record, using the access path of the file associated with the view ViewName.
It is possible to test whether the reading was successful by an instruction of the type:
|
IF ViewName EXISTS |
or |
IF ViewName DOES_NOT_EXIST. |
If the read operation is not completed successfully, the system will not read any records at all, and the values of the file fields will remain unchanged.
DOES_NOT_EXIST is TRUE if the beginning of the file is reached.
You can also check that the record is not locked, by testing it with the *LOCKED reserved word:
If *LOCKED = 1 |
The record is locked. |
If *LOCKED = 0 |
The record is not locked. |
By default, file records are locked after being read if the file's view ViewName is declared in update mode and the *UNLCK reserved word is not used.
See the UNLOCK instruction which enables a file record to be released.
If *UNLCK is mentioned, the reading does not lock the record. This parameter, used on a file opened in update mode, obtains the same effect as if it had been declared in read-only mode.
The *MR parameter allows you to generate read implicit management rules that are linked to the entity corresponding to the view, even if the program is generated without the option to generate implicit management rules.
The *NO_MR parameter allows you not to generate read implicit management rules that are linked to the entity corresponding to the view, even if the program is generated with the option to generate implicit management rules.
Example
Example for SALES file (file keys are customer code and line number);
SALES view is used only with W_CUST_CODE as access key.
SALES_CUST_CODE |
SALES_LINE_NBR |
0002 |
01 |
0002 |
02 |
0002 |
03 |
0002 |
04 |
0006 |
01 |
0006 |
02 |
0011 |
01 |
W_CUST_CODE = '0006'
READ_LAST SALES
*
* This will position the pointer on line 02 of customer 0006
*
DO_WHILE SALES EXISTS
PRINT_VIEWS DETAIL_LINE
READ_PREVIOUS SALES
* This reads all the records up to line 01 of customer 0002
REDO