Ü Difference
between READE and CHAIN operation
·
The search argument, |search-arg, must be the key or relative
record number used to retrieve the record.
·
The CHAIN command does a SETLL
and a READE in order to find a match. CHAIN is best used to locate a unique record (like a customer record).
·
SETLL with READE is best used
when there can be more than one record found. For example, you can find
multiple customer orders in your system for one unique customer.
·
In case of CHAIN, the file
operation is used to randomly retrieve a record from a file. The factor 1 value
is mandatory for chain operation. The factor 1 value must be key field or RRN.
·
In case of CHAIN the Resulting
indicator will be at HI position while in case of READE the indicator will be
at LOW position.
·
In case of CHAIN, if the record
is found then the pointer will be set, otherwise i.e., if the record does not
exist then the pointer will not set. This is the reason why we check with the
%Found keyword and moreover after reading the record (in case if the record
found and there is more number of records with the same keyword).
·
We cannot move to another
record, which meets the same criteria specified in the Chain operation. So the
conclusion is we cannot read more number of records with the Chain operation,
if there are more number of records exists with the same criteria in the file.
·
Whereas using READE, we can
read all the records which meet the same criteria using subsequent READE
operation. If there are no records with the specified criteria then the pointer
will be set to EOF.
·
In case the program uses a
SETLL / READE type loop to look for a particular record it needed. However,
once it is found the record it carries the processing of the loop until the end
of the file.