The following cases describe how the join logical file in Basic concepts of joining two physical files (example 1) presents
records to an application programs.
The PF1 file is specified first on the JFILE keyword, and is therefore
the primary file. When the application program requests a record, the system
does the following things:
- Uses the value of the first join field in the primary file (the Nbr field
in PF1).
- Finds the first record in the secondary file with a matching join field
(the Nbr field in PF2 matches the Nbr field in PF1).
- For each match, joins the fields from the physical files into one record
and provides this record to your program. Depending on how many records are
in the physical files, one of the following conditions might occur:
- For all records in the primary file, only one matching record is found
in the secondary file. The resulting join logical file contains a single record
for each record in the primary file. See Match records in primary and secondary files (case 1).
- For some records in the primary file, no matching record is found in the
secondary file.
If you specify the JDFTVAL keyword:
If you do not specify the JDFTVAL keyword:
- If a matching record in a secondary file exists, the system joins to the
secondary, or multiple secondaries. The result is one or more records for
each record in the primary file.
- If a matching record in a secondary file does not exist, the system does
not return a record.
Note: When the JDFTVAL is not specified, the system returns a record only
if a match is found in every secondary file for a record in the primary file.
In the following examples, cases 1 through 4 describe sequential read operations,
and case 5 describes reading by key.