ADELIA |
VADELIA |
SADELIA |
WADELIA |
MADELIA |
(I/B) |
(I/B) (S) |
(B) (S) |
(I/B) (S) |
(I) (S) |
Section for use
All
Syntax
READ_LAST ViewName Option Parameter
Option |
Þ |
*UNLCK | None |
|
|
|
Parameter |
Þ |
*NO_MR | *MR | None |
Description
For files having only one key field: this instruction corresponds to the positioning on the last record, having as a key the search argument, and to a backward reading (without comparing the file field value with the search argument)
( =
POSITION_AFTER +
READ_PREVIOUS).
For files having at least 2 key fields: this instruction corresponds to the positioning on the last record of a group, a backward reading and a comparison of the key of the record read with the search argument
( = POSITION_AFTER +
READ_P_EQUAL).
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.
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 = '0002'
READ_LAST SALES
*
* This will position the pointer on line 04 of customer 0002
*
LAST_NUMBER = SALES_LINE_NBR