Version

    Accessing Data Records and Fields

    This section describes the way how the record fields should be worked with. As you know, each component can have ports. Both input and output ports are numbered starting from 0.

    Metadata of connected edges must be identified by their names. Different metadata must have different names.

    Working with Records and Variables

    Since CloverETL 3.2, the syntax has changed to:

    $in.portID.fieldID and $out.portID.fieldID

    e.g., $in.0.* = $out.0.*;

    That way, you can clearly distinguish input and output metadata.

    Transformations you have written before will be compatible with the old syntax.

    Now we suppose that Customers is the ID of metadata, their name is customers, and their third field (field 2) is firstname.

    Following expressions represent the value of the third field (field 2) of the specified metadata:

    • $in.<port number>.<field number>

      Example: $in.0.2

      $in.0.* means all fields on the first port (port 0).

    • $in.<port number>.<field name>

      Example: $in.0.firstname

    • $<metadata name>.<field number>

      Example: $customers.2

      $customers.* means all fields on the first port (port 0).

    • $<metadata name>.<field name>

      Example: $customers.firstname

    You can also define records in CTL code. Such definitions can look like these:

    • <metadata name> MyCTLRecord;

      Example: customers myCustomers;

    • After that, you can use the following expressions:

      <record variable name>.<field name>

      Example: myCustomers.firstname;

    Mapping of records to variables looks like this:

    • myVariable = $in.<port number>.<field number>;

      Example: FirstName = $in.0.2;

    • myVariable = $in.<port number>.<field name>;

      Example: FirstName = $in.0.firstname;

    • myVariable = $<metadata name>.<field number>;

      Example: FirstName = $customers.2;

    • myVariable = $<metadata name>.<field name>;

      Example: FirstName = $customers.firstname;

    • myVariable = <record variable name>.<field name>;

      Example: FirstName = myCustomers.firstname;

      Mapping of variables to records can look like this:

    • $out.<port number>.<field number> = myVariable;

      Example: $out.0.2 = FirstName;

    • $out.<port number>.<field name> = myVariable;

      Example: $out.0.firstname = FirstName;

    • $<metadata name>.<field number> = myVariable;

      Example: $customers.2 = FirstName;

    • $<metadata name>.<field name> = myVariable;

      Example: $customers.firstname = FirstName;

    • <record variable name>.<field name> = myVariable;

      Example: myCustomers.firstname = FirstName;

    Remember that if the component has a single input port or single output port, you can use the syntax as follows:

    $firstname

    Generally, the syntax is:

    $<field name>

    You can assign input to an internal CTL record using the following syntax:

    MyCTLRecord.* = $in.0.*;

    Also, you can map values of an internal record to the output using the following syntax:

    $out.0.* = MyCTLRecord.*;