%Join - Metasql


%Join(COMMON_KEYS, PSAESECTDEFN ABC,  PSAESTEPDEFN XYZ)

Use COMMON_KEYS to specify that all common primary key fields are used in constructing a Where clause; use COMMON_FIELDS to specify all common fields, not just key fields. You can select either COMMON_KEYS or COMMON_FIELDS.

The example code results in the following being generated:
ABC.AE_APPLID = XYZ.AE_APPLID 
AND ABC.AE_SECTION = XYZ.AE_SECTION 
AND ABC.DBTYPE = XYZ.DBTYPE 
AND ABC.EFFDT = XYZ.EFFDT

Here's another example:

%Join(COMMON_FIELDS, PSAEAPPLDEFN ABC,  PSAESECTDEFN XYZ)

The second example results in the following being generated:

ABC.AE_APPLID = XYZ.AE_APPLID 
AND ABC.DESCR = XYZ.DESCR

However, you do not want to perform the join using the DESCR field because it's a long field. Instead use override_field, as shown in the following code:

%Join(COMMON_FIELDS, PSAEAPPLDEFN ABC,  PSAESECTDEFN XYZ, DESCR)

This example results in the following being generated:

ABC.AE_APPLID = XYZ.AE_APPLID

Comments