ADELIA |
VADELIA |
SADELIA |
WADELIA |
MADELIA |
(I/B) |
(I/B) (S) |
(B) (S) |
(I/B) (S) |
(I) (S) |
Section for use
All
Syntax
READ ViewName Option Parameter
Option |
→ |
*UNLCK | None |
|
|
|
Parameter |
→ |
*NO_MR | *MR | None |
Description
This instruction involves the reading of the next 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 end 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'
POSITION_BEFORE SALES
* This will position the pointer in the file before line 01 of customer 0006
*
IF SALES EXISTS
READ SALES
* This reads the record of customer 0006 / line 01
DO_WHILE SALES EXISTS
PRINT_VIEWS DETAIL_LINE
READ SALES
* This reads all the records from customer 0006/line 01.
* All the records will be read until the end of the file.
REDO
ELSE
PRINT NO_SALE_LINE
END