ESQL ROW data type

The ROW data type holds a tree structure. A row in a database is a particular type of tree structure, but the ROW data type is not restricted to holding data from database rows.

In a database, a row is a fixed, ordered, set of scalar values. A scalar is defined as a single entity value or a string.

A database table is an unordered set of rows and therefore represents a two dimensional "array" of scalar values, in which one dimension is fixed and the other is variable. In ESQL, a row is an open-ended, ordered, set of named values in which each value can be scalar, or another row. That is, a row is an open-ended tree structure with no restrictions on dimensions or regularity. Consider the following diagram:
Root
  Row
    PartNumber  = 1
    Description = 'Chocolate bar'
    Price       = 0.30
  Row
    PartNumber  = 2
    Description = 'Biscuit'
    Price       = 0.35
  Row
    PartNumber  = 3
    Description = 'Fruit'
    Price       = 0.42

In the example, Root contains three elements all named Row. Each of these elements in turn contains three elements with different names and values. This diagram equally describes an instance of an ESQL row data type (that is, a tree structure) or the contents of a database table.

New ROW variables created using ESQL always have an IBM® MQ Root parser. For more information about Root parsers, see Root parsers.

ROW and LIST

The ROW data type is a normal data type. You can use the DECLARE statement to create ROW variables in the same way as you create INTEGER or CHARACTER variables. There is also a more general concept of a ROW data type. In the previous example, Root is the root element of a ROW variable. Each of the elements called Row, while not the root element of ROW variables, is a root element of substructures. Many ESQL operations (and particularly the SELECT function) work with the general concept of ROW and operate equally on whole trees or parts of trees.

There is also a general concept of a LIST data type. The set of elements called Row can be regarded as a list. Some ESQL operations (particularly SELECT) work with the general concept of list.

InputRoot, OutputRoot, and so on, are examples of ROW variables that are automatically declared and present in the data structure, ready for use.