Figure 46 and Figure 47 show how to specify the JDUPSEQ keyword.
Figure 46. 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 46, 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 47 assumes the logical file is based on the same physical files as Figure 46. There are three records for Anne in PF2, showing three telephone numbers, as shown in Figure 47.
Figure 47. 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.
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.