Sign in

docs DDS Physical

Example 2: Specifying the key field

Example: Specifying the key field for logical files

Example 2: Specifying the key field

In this example, a logical file views the same two physical files as in Example 1, but the second record format in the logical file has *NONE specified in key position 2.

Figure 1. Specifying the key field

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A          R CLSHST                    PFILE(CLSHSTP)
00020A          K EMPNBR  1
00030A          K CLSDTE  2
00040A*
00050A*
00060A          R JOBHST                    PFILE(JOBHSTP)
00070A          K EMPNBR  1
00080A          K *NONE   2
00090A          K JOBDTE  3
     A
Record formatKey positions
123
CLSHSTEMPNBRCLSDTE*NONE
JOBHSTEMPNBR*NONEJOBDTE

As in the example in the Using *NONE in the key field when creating a DDS file topic, all records from the two physical files are first merged and sequenced together on employee number (EMPNBR). However, the records for each student are merged and sequenced first on class date (CLSDTE) and then on job assignment date (JOBDTE). The set of records used for that example are now retrieved as follows:

EMPNBRCLSDTEJOBDTEDescription
10053/79Completed class
10054/79Left to begin new job
10056/79Completed class
10054/79Completed job
10063/79Completed class
10065/79Transferred to new location
10061/79Completed job
10062/79Completed job
10078/79Left because of illness
10071/79Completed job
10074/79Completed job
10077/79Completed job

When several adjacent record formats have *NONE in the same key position, they form a set, relative to record formats specified before and after them, that functions in sequencing as an individual record format. Key fields specified after *NONE serve to merge and sequence records of the formats within the set.