ROW

Synopsis

HELP:   A set of different row/table formats that can be read
TYPE:   OBJECT
SYNTAX: ROW[(NAME['str'...],COLUMN/COL[()...],MAXLEN/FIXLEN=num,IGNRST,IGNEMP,PATH/ROOT='str',FORMAT=FIX/LFD/DLM/ARY/VAR/CSV/TVD/XML,DEFAULTS(),POT[()...],NEXT='str',DRAIN,ONETIME)...]

Description

Tables are read row-by-row. This object must be used to describe the structure of each row in a table.

The maximum length of one row can be limited by specifying the MAXLEN parameter. This is especially important for unstructured data if more than one row specification is used because it may help to detect the correct row specification that applies to the currently processed row.

If specifying a fixed or variable length format, by default, the 'MAXLEN' parameter is set to a reasonable value (sum of each length). For fixed length formats, the record length must be equal to the calculated length of this row and for variable formats, the record length must smaller than or equal to the defined maximal length. For structured formats like XML, the maximum length check is also available, but usually does not make much sense because the bytes occupied by one row needs is not known a priori for such data formats.

To simplify the specification of columns, a format specifier and several default values can be specified. These settings will override the corresponding settings of the table object.

Any conversions are performed per column. Data formats, character sets and various conversions can be mixed at will. If XML documents are parsed, the format for all columns must be XML.

If the table processing method is RECORD, then you can activate switches to ignore empty records (record length = 0) or a remaining rest at the end of the line. This can be used to suppress columns at the end of the record.

The table name is a logical qualifier which can later be used to address the table. If a structure is to be used for more than one format, several names can be assigned to this row specification. In this case, all column names must be unique across all these formats. The first name that is defined is the logical name for this format, all others are aliases that are only permitted when comparing the row specifications.

Additionally, a path can be defined for different structured formats (like XML). This path is appended to the root path provided for the table and serves as prefix for the per-column path. If no path is provided, the logical table name is used.

A row specification supports many powerful features which can be accessed with the parameters below.

NEXT -- Static Row-Level Routing

NEXT='name' sets the preferred start of the auto-detect rotation after this row specification matches successfully. It does NOT lock the format, so autodetect remains active. If a different row type appears in the data stream, the rotation will still find the matching row specification -- it simply starts from the preferred successor instead of cycling from index 0. The name must match the logical name or an alias of another row specification in the same table.

NEXT is designed for multi-format streams where each logical block begins with a type record (such as a segment header in an IMS unload file) that unambiguously identifies the layout of the data records that follow. Each format must appear as an individual, self-contained record in the input stream (one record per row spec). If a single row spec spans multiple physical records, NEXT will not behave as expected.

For dynamic routing where the successor row spec name is carried in a column value rather than being fixed at definition time, use the NEXT switch on the column instead. See the column read man page for details.

Recognition Requirement

When multiple row specifications are present, autodetect tries each spec in rotation. A data row spec will be tried for every record that fails all preceding specs. If a data row spec has no discriminator on column 1, it may accidentally match a control row (header or trailer) that was not rejected by earlier specs, producing silently wrong output.

The correct discriminator for data rows is a negative lookahead regex on column 1 that explicitly rejects all known control row identifiers. Do NOT rely on MAXLEN alone: a control row identifier that happens to fit within the length limit will pass through and be misread as a data row.

Correct pattern (rejects records whose first column starts with a control row prefix):

col(name=field1 regexp(pattern='^(?!SEGA|SEGB)' fmterr))

The fmterr flag is mandatory: it turns a regex mismatch into a format error (FLMRTC_FMT), which triggers autodetect rotation to the next spec. Without fmterr, a mismatch would be a hard error.

Note that data row specs with the same column structure (e.g., two specs that both hold two string fields) cannot be distinguished from each other by content alone. Their disambiguation relies entirely on NEXT routing from the preceding control row.

Example (IMS unload style: two distinct segment types, each identified by a type record that statically names the following data layout):

read.text(file=stream.csv table(format=CSV row(name=SEGA_HDR col(name=type regexp(pattern='^SEGA$' fmterr)) col(name=info) next='SEGA_DATA') row(name=SEGB_HDR col(name=type regexp(pattern='^SEGB$' fmterr)) col(name=info) next='SEGB_DATA') row(name=SEGA_DATA col(name=field1 regexp(pattern='^(?!SEGA|SEGB)' fmterr)) col(name=field2)) row(name=SEGB_DATA col(name=key regexp(pattern='^(?!SEGA|SEGB)' fmterr)) col(name=value))))

After a SEGA_HDR record matches, the auto-detect rotation starts at SEGA_DATA for the next record rather than from the beginning of the list. SEGA_DATA and SEGB_DATA are intentionally structurally identical (two string columns); only NEXT routing disambiguates them. The regex on column 1 ensures that control rows are never mistaken for data rows during autodetect rotation.

DRAIN -- Suppress Row Output

DRAIN suppresses output for a row while all parsing and routing still applies. When DRAIN is active, the record is parsed normally and NEXT routing fires if defined, but the row is not forwarded to the output. Use DRAIN for type or control records that serve only to identify or route the following data records and must not appear in the output.

Unlike NEXT, DRAIN has no restriction on the number of physical records per logical row spec. It can be applied to any row specification regardless of whether the table uses single-record or multi-record rows.

SKIP is accepted as an alias for DRAIN on the read side. On the write side the keyword is SKIP (with DRAIN as alias).

ONETIME -- Restart Row Probe After a Single Match

ONETIME marks the row spec as a one-shot match: after this row validates a single record, the probe anchor is discarded and the next record re-enters the probe from row 0. Effectively the row is valid for the current record only, then the table cycle is treated as complete and a fresh cycle begins for the next record.

Typical use: a catch-all drain row placed last in the row list, which absorbs header, trailer, and other boundary records that no data row accepted. Without ONETIME the catch-all becomes "sticky" -- once matched, the probe anchor stays on it and every subsequent record is silently drained. With ONETIME the probe returns to row 0 and the next record is first offered to the real data specs again.

ONETIME is orthogonal to DRAIN, IGNRST, and NEXT: it only affects where the probe resumes for the NEXT record. The current record is processed by the ONETIME row normally (drained if DRAIN, emitted otherwise).

FMT2TAB schema compilation emits ONETIME automatically on the catch-all drain rows it generates (IMS_EOF in IMSL/IMSS mode, IHDU_UNKNOWN in IHDU mode). Hand-written schemas that declare their own catch-all row should set ONETIME explicitly:

row(name=GENERIC_EOF drain ignrst onetime)

Arguments