Figure 53 and Figure 54 show how to specify the JDUPSEQ keyword.
Figure 53. Specifying the JDUPSEQ Keyword (Example 1)
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 00010A R JREC JFILE(PF1 PF2) 00020A J JOIN(PF1 PF2) 00030A JFLD(NAME1 NAME2) 00040A JDUPSEQ(PHONE) 00050A NAME1 00060A ADDR 00070A PHONE
Figure 53, assumes that PF1 and PF2 have the following records:
| PF1 NAME1 | ADDR | PF2 NAME2 | TELEPHONE |
|---|---|---|---|
| Anne | 120 1st St. | Anne | 555-1111 |
| Doug | 40 Pillsbury | Anne | 555-6666 |
| Mark | 2 Lakeside Dr. | Anne | 555-2222 |
|
|
| Doug | 555-5555 |
There are three records for Anne in PF2, showing three telephone
numbers. With JDUPSEQ specified as shown, the records are returned as
follows:
| NAME | ADDR | TELEPHONE |
|---|---|---|
| Anne | 120 1st St. | 555-1111 |
| Anne | 120 1st St. | 555-2222 |
| Anne | 120 1st St. | 555-6666 |
| Doug | 40 Pillsbury | 555-5555 |
The JDUPSEQ keyword only affects the order of records when duplicates exist.
Figure 54 assumes the logical file is based on the same physical files as Figure 53. There are three records for Anne in PF2, showing three telephone numbers, as shown in Figure 54.
Figure 54. Specifying the JDUPSEQ Keyword (Example 2)
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A R JREC JFILE(PF1 PF2)
00020A J JOIN(PF1 PF2)
00030A JFLD(NAME1 NAME2)
00040A JDUPSEQ(PHONE *DESCEND)
00050A NAME1
00060A ADDR
00070A PHONE
A
When you specify JDUPSEQ with *DESCEND, the records are returned as
follows:
| NAME1 | ADDR | TELEPHONE |
|---|---|---|
| Anne | 120 1st St. | 555-6666 |
| Anne | 120 1st St. | 555-2222 |
| Anne | 120 1st St. | 555-1111 |
| Doug | 40 Pillsbury | 555-5555 |
The list shows Anne's telephone numbers in descending order.