COLUMN

Synopsis

HELP:   Description of all columns in the row
TYPE:   OBJECT
SYNTAX: COLUMN/COL[(NAME='str',FORMAT.{},PROCESS[{}...],TYPE.{},MINLEN=num,MAXLEN/FIXLEN=num,PATH='str',ROOT='str',VALUE='str',CHANGE='str',VARFMT=PLENPTR/ALENPTR/PPTRLEN/APTRLEN/PFLGLENPTR/PPTRLENFLG/PCLNDLNCOLDAT/PFLGCLNDLNCOLDAT/AFLGCLNDLNCOLDAT,REGEXP(),MATCH(),INDEX(),POT='str',LOOKUP,NOCASE,LITERAL,UPDATE,NOTMTD=ZERO/MASK/RAND/IBAN,NEXT,DRAIN)...]

Description

This object is used to describe how to extract a specific column from each row. Optional pre-processing steps (e.g. decryption) can be applied separately before a conversion to a neutral data type is done as last step for every column. The neutral format of the extracted data can be validated using a regular expression.

For archiving the read data, their indexing and pot design can be optionally provided here. Indexing is a must if you want to calculate signatures for the later search.

The column name is a logical qualifier which can later be used to address the column. For different supported structured formats, a path can be specified. This path is appended to the root path which may be specified in table and row objects. If no path is provided, the logical column name is used.

To simplify the specification of formats, processes and types, several default values can be specified. These settings will override the corresponding settings of the row object.

As part of the end of table handling you can define a logical table name over the keyword 'CHANGE' which activates monitoring of changes in this column, which will result in a EOT return code if a change is detected. In such a case the table name defined in this column specification is used in the EOT handling process. You can place a star character (*) in the change string. The first star in the string will be replaced by a string representation of the changed column value. For example:

   col(name='GENDER' change='TAB*')

   "GENDER","NAME" ,"AGE"
   "M"     ,"Hugo" ,"43"
   "M"     ,"Pope" ,"32"
   "F"     ,"Maria","42"
   "M"     ,"Mike" ,"17"
   "F"     ,"Magd" ,"39"

The CSV table can now be split in male and female, depending on the character in the column GENDER and the table names given after EOT are 'TABM' and TABF'. At write you can only request the name and the age and the EOT handling can be used to produce 2 tables one with all female and another with all male entries.

This column change detection support was mainly introduced for users using only one row specification for different tables in XML. The first row will result in a table change, except if it is identical to the set default value for this column, because each use of a new row definition will start with this default as previously stored column values. If no default value is specified, for string and binary columns an empty string ('') and for integer and float the number zero ('0') is used. With this mechanism, you can control the EOT handling in the start phase of a table. You can ensure that the first EOT gives the first column with a defined change, if the default value is different to the value expected for this column or you can ensure to get the name of the row specification after the first EOT if all defaults match the expected values of the first row in the table. Later on, a row definition change will result in EOT and if you come back to a previous row definition, the old values are still used for compare.

If the first data block does not contain a complete row, you still get the table name of the first defined row specification. This mechanism only works in the expected manner if the block size is larger than the space required for the longest row.

For writing to a FLAM archive, you can also define the indexing of the columns when reading, which can be used later to search and change the compressed and encrypted data without having to pack all segments of a member. In this case for columns of the string data type, you can use the NOCASE switch to force the conversion of all upper case Latin letters (U0041-U005A) to lower case letters (U0061-U007A) for the signature generation, which then also applies to the data comparison. This makes it possible to realize non-case sensitive comparisons, but this must be taken into account when writing the data to the archive.

For archiving, a lookup table can also be requested for the column, which ensures that the data is unique and is particularly useful if multiple searches have to be performed in the same matrix.

You can also mark a column as a literal. In this case, the data is not stored in the corresponding pot, but in the global literal matrix, which is particularly useful for keywords.

If you describe a record for an update, you must be able to define which columns are to receive a new value. These can also be indexed columns or columns that are marked as primary keys. This must therefore be indicated here via a separate update flag.

If access to a column has been restricted via the key rights, the method for handling these columns can be adapted here. If you select a method here that manipulates the data (MASK, RAND, IBAN), the matrix can no longer be written back. These methods can therefore only be used when reading.

NEXT -- Dynamic Row-Level Routing via Column Value

The NEXT switch on a column enables dynamic routing of the auto-detect rotation based on the value read from that column at runtime. When NEXT is active on a column, the string value extracted from that column during parsing is interpreted as the name of the row specification to use as the starting point of the next auto-detect cycle. This allows the input stream itself to carry the routing information rather than requiring a fixed mapping at definition time.

This is the dynamic counterpart to the static NEXT='name' parameter on the row specification. Use the column-level NEXT when a single control record type introduces multiple different data formats and the actual target row spec name is encoded in one of its columns. Use the static row-level NEXT='name' when the successor row spec is always the same for a given row spec type.

The same restriction as for row-level NEXT applies: this mechanism is designed for streams where each logical block consists of individual, self-contained records (one record per row spec). If a row spec spans multiple physical records, NEXT will not behave as expected.

Example (IMS unload style: a single generic segment header record carries the segment type name in one column, which determines the layout of the data records that follow):

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

In this example the SEG_HDR record has a second column (segname) that carries the name of the data row spec to expect next (e.g. 'SEGA_DATA' or 'SEGB_DATA'). The NEXT switch on that column routes the auto-detect to the named row spec for the records that follow. DRAIN on SEG_HDR and END_HDR ensures that only the data records are forwarded to the output.

The negative lookahead regex on column 1 of SEGA_DATA and SEGB_DATA rejects records whose first field starts with a control row identifier ('SEG_HDR' or 'END_HDR'). This is required because autodetect may try data row specs for control records during rotation; without this guard a control record can be silently misread as a data row. Do NOT rely on MAXLEN alone for this purpose: a control row identifier that fits within the length limit will pass the check and produce wrong output.

DRAIN -- Consume Column Bytes Without Producing an Element

The DRAIN switch instructs the read-side to consume the bytes for this column from the input record as usual (FORMAT processing still applies for length determination), but to suppress the column entirely: no element is added to the element list, no type conversion is performed, and the column does not appear in the table header passed to the write side. This makes the column completely invisible to subsequent processing, regardless of the output format.

DRAIN is format-independent: it applies equally to CSV, binary, XML, and any other write format. The column bytes are consumed and discarded; only the FORMAT definition is needed to determine the byte range.

When paired with the SKIP switch on the corresponding column in the write-side row specification, the column is suppressed end-to-end: the read side discards it and the write side omits it from the output without requiring any element from the element list.

The main use case is FILLER bytes in COBOL record layouts. The BCSV COBOL compiler sets DRAIN on FILLER columns automatically (together with write-side SKIP) when STYLE.FILLER=SKIP is active. The FILLER bytes advance the byte pointer correctly and leave no trace in the output.

Note: DRAIN and SKIP must be used together. If a write-side column names a DRAIN'd column without SKIP, the write side will not find that column in the table header. Unless a default value is provided for that column (INSERT=POSSIBLE), this results in an error.

Example (suppress a 4-byte FILLER gap between two data columns):

read.binary(file=record.bin table(format=ORG row(name=CUSTOMER col(name=ID format.fix(length=4) type.integer()) col(name=_filler_ format.fix(length=4) type.binary() drain) col(name=NAME format.fix(length=20) type.string()))))

The corresponding write-side row spec must set SKIP on filler so that column is omitted from the output:

write.text(file=out.csv table(format=CSV row(name=CUSTOMER col(name=ID) col(name=_filler_ skip) col(name=NAME))))

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

Arguments