Joining Three or More Physical Files (Example 7)

You can use a join logical file to join as many as 32 physical files. These files must be specified on the JFILE keyword. The first file specified on the JFILE keyword is the primary file; the other files are all secondary files.

The physical files must be joined in pairs, with each pair described by a join specification. Each join specification must have one or more join fields identified.

The following shows the fields in the files and one field common to all the physical files in the logical file:
Examples of Records

In this example, the Name field is common to all the physical files (PF1, PF2, and PF3), and serves as the join field.

The following shows the DDS for the physical and logical files:



JLF
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
     A          R JOINREC                   JFILE(PF1 PF2 P3)
     A          J                           JOIN(PF1 PF2)
     A                                      JFLD(NAME NAME)
     A          J                           JOIN(PF2 PF3)
     A                                      JFLD(NAME NAME)
     A            NAME                      JREF(PF1)
     A            ADDR
     A            TELEPHONE
     A            SALARY
     A          K NAME
     A
 
PF1
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
     A          R REC1
     A            NAME          10
     A            ADDR          20
     A          K NAME
     A
 
PF2
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
     A          R REC2
     A            NAME          10
     A            TELEPHONE      7
     A          K NAME
     A
 
PF3
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
     A          R REC3
     A            NAME          10
     A            SALARY         9  2
     A          K NAME
     A

Assume the physical files have the following records:
Examples of Records

The program reads the following logical file records:
Examples of Records

No record is returned for Tom because a record is not found for him in PF2 and PF3 and the JDFTVAL keyword is not specified. No record is returned for Sue because the primary file has no record for Sue.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]