Using the CONCAT keyword, you can combine two or more fields from
a physical file record format to make one field in a logical file record format.
For example, a physical file record format contains the fields Month, Day,
and Year. For a logical file, you concatenate these fields into one
field, Date.
The field length for the resulting concatenated field is the sum of the
lengths of the included fields (unless the fields in the physical file are
binary or packed decimal, in which case they are changed to zoned decimal).
The field length of the resulting field is automatically calculated by the
system. A concatenated field can have:
- Column headings
- Validity checking
- Text description
- Edit code or edit word (numeric concatenated fields only)
Note: This editing and validity checking information is not used by the
database management system but is retrieved when field descriptions from the
database file are referred to in a display or printer file.
When fields are concatenated, the data types can change (the resulting
data type is automatically determined by the system). The following rules
and restrictions apply:
- The operating system assigns the data type based on
the data types of the fields that are being concatenated.
- The maximum length of a concatenated field varies depending on the data
type of the concatenated field and the length of the fields being concatenated.
If the concatenated field is zoned decimal (S), its total length cannot exceed
31 bytes; if it is character (A), its total length cannot exceed 32 766 bytes.
- In join logical files, the fields to be concatenated must be from the
same physical file. The first field specified on the CONCAT keyword identifies
which physical file is to be used. The first field must, therefore, be unique
among the physical files on which the logical file is based, or you must also
specify the JREF keyword to specify which physical file to use.
- The use of a concatenated field must be I (input only) if the concatenated
field is variable length. Otherwise, the use can be B (both input and output).
- REFSHIFT cannot be specified on a concatenated field that has been assigned
a data type of O or J.
- If any of the fields contain the null value, the result of concatenation
is the null value.
When
only numeric fields are concatenated, the sign of the last field in the group
is used as the sign of the concatenated field.
Notes: - Numeric fields with decimal precision other than zero cannot be included
in a concatenated field.
- Date, time, timestamp, and floating-point fields cannot be included in
a concatenated field.
The following example shows the field description in data description specifications
(DDS) for concatenation. (The CONCAT keyword is used to specify the fields
to concatenate.)
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
A
00101A MONTH
00102A DAY
00103A YEAR
00104A DATE CONCAT(MONTH DAY YEAR)
A
In this example, the logical file record format includes the separate fields
of
Month,
Day, and
Year, as well as the concatenated
Date field.
Any of the following formats can be used:
- A format with the separate fields of Month, Day, and Year
- A format with only the concatenated Date field
- A format with the separate fields Month, Day, Year and
the concatenated Date field
When both separate and concatenated fields exist in the format, any updates
to the fields are processed in the sequence in which the DDS is specified.
In the previous example, if the Date field contained 103188 and the Month field
is changed to 12, when the record is updated, the month in the Date field
would be used. The updated record would contain 103188. If the Date field
were specified first, the updated record would contain 123188.
Concatenated fields can also be used as key fields and select/omit fields.