JOIN Control Statement - mfx - 3.1

Syncsort™ MFX Programmers Guide

Product type
Software
Portfolio
Integrate
Product family
Syncsort™ Software
Product
Syncsort™ MFX > MFX
Version
3.1
Language
English
ContentType
Programmer’s Guide
Product name
Syncsort™ MFX
Title
Syncsort™ MFX Programmers Guide
Topic type
How Do I
Copyright
2024
First publish date
2010
ft:lastEdition
2024-08-27
ft:lastPublication
2024-08-27T08:14:56.318001

The JOIN control statement specifies the disposition of paired and unpaired records in a join.

When you do not provide a JOIN control statement in an application that has JOINKEYS control statements, MFX produces an output from the join operation that includes all paired records (an “inner join”). All unpaired records from both SORTJNF1 and SORTJNF2 are discarded. By providing a JOIN control statement, you can specify that unpaired records are to be included in the join output (an “outer join”). Parameters of the JOIN statement provide options as to which of the unpaired records are to be retained for output.

See the descriptions of the JOINKEYS and REFORMAT control statements for additional information.

JOIN Control Statement Format

The format of the JOIN control statement is illustrated below:
Figure 1. JOIN Control Statement Format

Retaining Unpaired Records

When joining files, a record from one file may or may not have a match in the other file. A match occurs when the contents of the join keys in the record from the first file equal the contents of the join keys in the record from the second file.

By specifying the JOIN statement you can discard unpaired records from one or both files, or retain unpaired records from both files.

To retain unpaired records from SORTJNF1 (a “left outer join”) in addition to all joined records, specify:
Figure 2. Sample JOIN Statement to Retain Unpaired Records from SORTJNF1

To retain unpaired records from SORTJNF2 (a “right outer join”) in addition to all joined records, specify:
Figure 3. Sample JOIN Statement to Retain Unpaired Records from SORTJNF2

To retain unpaired records from both SORTJNF1 and SORTJNF2 (a “full outer join”) in addition to all joined records, specify either:
Figure 4. Sample JOIN Statement to Retain Unpaired Records from SORTJNF1/2

or simply:

Figure 5. Sample JOIN Statement to Retain Unpaired Records from SORTJNF1/2

Discarding Paired Records

You have the option of discarding the paired records from a join and keeping only the unpaired ones. To do this, specify:
Figure 6. Sample JOIN Statement to Discard Paired Records

If you want to keep only the unpaired records from one SORTJNF1 or SORTJNF2, add either the F1 or the F2 parameter.

Note: See the description of the REFORMAT statement for a discussion on what will appear in the record created by join processing when source fields from either SORTJNF1 or SORTJNF2 are not available due to a join unpaired operation.

For more information, see Joining Records from Multiple Files.