Example 9: Using defaults for missing records from secondary files
This example shows how to use the default value for a missing join field in a secondary file to join to the other secondary file.
If the DFT keyword is specified in the secondary file, the value specified for the DFT keyword is used in the logical file.
The data description specifications (DDS) for the files are shown as follows:
JLF |...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 A JDFTVAL A R JRCD JFILE(PF1 PF2 PF3) A J JOIN(PF1 PF2) A JFLD(NAME NAME) A J JOIN(PF2 PF3) A JFLD(TELEPHONE TELEPHONE) A NAME JREF(PF1) A ADDR A TELEPHONE JREF(PF2) A LOC APF1 |...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 A R RCD1 A NAME 20 A ADDR 40 A COUNTRY 40 A
PF2 |...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 A R RCD2 A NAME 20 A TELEPHONE 8 DFT('999-9999') A
PF3 |...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 A R RCD3 A TELEPHONE 8 A LOC 30 DFT('No location assigned') A
Assume that PF1, PF2, and PF3 have the following records.
Table 1. Physical file 1 (PF1) Name Address Country Anne 120 1st St. USA Doug 40 Pillsbury Canada Mark 2 Lakeside Dr. Canada Sue 120 Broadway USA
Table 2. Physical file 2 (PF2) Name Telephone Anne 555–1234 Doug 555–2222 Sue 555–1144
Table 3. Physical file 3 (PF3) Telephone Location 555–1234 Room 312 555–2222 Main lobby 999–9999 No telephone number With JDFTVAL specified in the join logical file, the program reads the following logical file records.
In this example, complete data is found for Anne and Doug. However, part of the data is missing for Mark and Sue.
Table 4. Join logical file (JLF) Name Address Telephone Location Anne 120 1st St. 555–1234 Room 312 Doug 40 Pillsbury 555–2222 Main lobby Mark 2 Lakeside Dr. 999–9999 No telephone number Sue 120 Broadway 555–1144 No location assigned
- PF2 is missing a record for Mark because he has no telephone number. The default value for the Telephone field in PF2 is defined as 999-9999 using the DFT keyword. In this example, therefore, 999-9999 is the telephone number returned when no telephone number is assigned. The JDFTVAL keyword specified in the join logical file causes the default value for the Telephone field (which is 999-9999) in PF2 to be used to match with a record in PF3. (In PF3, a record is included to show a description for telephone number 999-9999.) Without the JDFTVAL keyword, no record would be returned for Mark.
- Sue's telephone number is not yet assigned a location; therefore, a record for 555-1144 is missing in PF3. Without JDFTVAL specified, no record would be returned for Sue. With JDFTVAL specified, the system supplies the default value specified on the DFT keyword in PF3 the Loc field (which is No location assigned).
Parent topic:
Setting up a join logical file