Control Items

Control items are maintained by the system. User programs can access control items, but cannot modify them. Although programs cannot directly alter control items, certain requests to the Enterprise Database Server can cause them to be modified.

The following types of control items are maintained by the system:

<control items>

──┬─<aggregate items>─────────────────┬───────────────────────────────┤
  ├─<count items>─────────────────────┤
  ├─<population items>────────────────┤
  ├─<record type items> ──────────────┤
  ├─<restart data set control items>──┤
  └─<data set control items>──────────┘ 

Each control item type is described in the following text.

Aggregate Items

An aggregate item is a count or sum maintained by the Enterprise Database Server that is based on data items in a data set. An aggregate item is updated during ENDTRANSACTION processing, which avoids a requirement to lock global data during a transaction, and also keeps other jobs from seeing partially updated information before the transaction is committed.

For embedded structures, the aggregate items are declared in the master structure. The value is updated immediately after an embedded record is stored or deleted. This is because the population or aggregate information for embedded structures is based on the master record instead of the embedded structure itself. For every master record, the population item contains the total of embedded records belonging to this master. There is no need to hold the value until ENDTRANSACTION. However, to maintain the consistency and integrity of the database when aggregate items are declared, the INDEPENDENTTRANS, LOCK TO MODIFY DETAILS, and REAPPLYCOMPLETED options are required.

The following diagrams illustrate the syntax for an aggregate item:

<aggregate item>

──<aggregate item name>─┬───────────┬─ AGGREGATE ──────────────────────►
                        └─<comment>─┘

►─<size specification>──<aggregate type>───────────────────────────────┤

<size specification>

── ( ─┬─────┬─<precision>─┬─────────────────────┬─ ) ──────────────────┤
      └─ S ─┘             └─ , ──<scale factor>─┘

<aggregate type>

──┬─ SUM ── ( ──<arithmetic expression>── ) ─┬─ OF ──<data set name>───┤
  └─ COUNT ── ( ──<Boolean expression>── ) ──┘

The following table explains the elements of the syntax diagrams:

Option

Description

<aggregate item name>

An aggregate item name is an identifier that names the item. An aggregate item name cannot exceed 30 characters.

If an aggregate item refers to an embedded data set and the item is declared as part of a master record, to add or delete records from the embedded data set, the master record must be selected again through either a FIND operation or a LOCK operation. Reselecting the master record ensures that the aggregate values in the user work area are the current values.

<aggregate type>

An aggregate type specifies the type of the aggregate item. A sum item provides a total sum of the arithmetic expression for all records in a data set. For any item that appears in the expression, the DASDL compiler implicitly makes the item a required item. A count item maintains the total count of records in a data set where the specified condition is satisfied. The system automatically adjusts the value of aggregate items when records are added, deleted, and modified.

<precision>, <scale factor>

The precision and scale factor for an aggregate item are identical to precision and scale factor for number type items. Aggregate items are stored in the same format as number type items.

The precision specifies the total number of numeric digits in the item. The scale factor specifies the number of digits to the right of the decimal point. The precision and scale factor must be unsigned integers. When an S appears before the precision, the item includes a sign. Maximum precision for an unsigned item is 23 decimal places, and for signed items it is 22 decimal places. The scale factor must not exceed the precision.

More than one aggregate item can be declared for each data set. When a data set item is used to compute the aggregate value for the data set, this item must be a number item. It can be single or double precision.

Example

The following example illustrates the use of aggregate items:

D1 DATA SET
 (
  D1-ID1          NUMBER(10);
  D1-ID2          ALPHA(10);
  D1-ID3          NUMBER(5);
  D1-ID4          NUMBER(2);
 );
 G1 AGGREGATE (S12) SUM (D1-ID1 + D1-ID3 - D1-ID4) OF D1;
 G2 AGGREGATE (4) COUNT (D1-ID2 NEQ "ABC") OF D1;

Count Items

Count items are used with counted links. Any data set that is referenced by a counted link must contain one count item. A count item contains a binary integer value that indicates the number of counted links which refer to the record. The system automatically adjusts the value in the count item to reflect the number of links that currently reference the record. Records that contain a nonzero count value cannot be deleted. Any program that attempts to delete such a record receives an exception and the deletion is not performed. User programs can examine the value of a count item, but cannot modify it.

Each data set can have a maximum of one count item. Count items cannot be used as keys.

The following diagram illustrates the syntax for count items:

<count item>

──<count item name>─┬───────────┬─ COUNT ( <unsigned integer> ) ───────┤
                    └─<comment>─┘

Option

Description

<count item name>

The count item name is an identifier that names the item. The count item name cannot exceed 30 characters.

<unsigned integer>

The unsigned integer specifies the maximum number of counted links that can point at the record simultaneously. An attempt to assign too many links to a single record results in an exception being returned to the program doing the assigning. The unsigned integer also determines the size of the count item. The count item always occupies an integral number of 4-bit digits, and sufficient digits are allocated to contain the binary representation of the unsigned integer.

Example

The following DASDL data set declarations include counted items:

D DATA SET
 (
  L IS IN E COUNTED;
  A ALPHA(3);
 );
E DATA SET
 (
  C COUNT (10);
  N NUMBER(5);
 );

Population Items

Population items provide a user-accessible count of the records in a data set, set, or subset. The system automatically adjusts the value of population items as records are added and deleted. User programs can examine the value of a population item, but cannot modify it.

Only one population item can be declared for each data set, set, or subset. Population items for disjoint structures are declared with global data. Population items for embedded structures must reside in the master record for the structure.

A data set declaration population item, unlike the data set physical options or set-subset physical options population items, does not limit the population or affect the physical attributes of the data set, set, or subset.

The following diagram illustrates the syntax for a data set population item:

<population item>

──<population item name>─┬───────────┬─────────────────────────────────►
                         └─<comment>─┘

►─ POPULATION ( <unsigned integer> ) OF ─┬─<data set name>─┬───────────┤
                                         ├─<set name>──────┤
                                         └─<subset name>───┘

The following table explains the elements of the syntax diagram:

Option

Description

<population item name>

A population item name is an identifier that names the item. The population item name cannot exceed 30 characters.

<unsigned integer>

The unsigned integer is used to determine the field size of the population item. The population item always occupies an integral number of 4-bit digits, and sufficient digits are allocated to contain the binary representation of the unsigned integer. If the actual population exceeds the maximum value that can be stored, the population item contains the remainder of the population item divided by the capacity of the population item (modulo).

Example

The following example illustrates the use of the data set population item:

POP-D POPULATION (1000) OF D;
D DATA SET
 (
  POP-S POPULATION (100) OF S;
  A ALPHA(3);
  E DATA SET
   (
    R REAL;
    F FIELD(20);
   );
  S SET OF E KEY IS F;
 );

Record Type Items

A data set can contain at most one record type item. A record type item declared in the fixed-format part of a record accomplishes two things. It signals the DASDL compiler that a variable-format record is being described, and it causes a record type item to be allocated.

A variable-format record consists of two parts: a fixed part and a variable part. A single record description exists for the fixed part. The variable-format part can describe several variable parts, each of which is identified by a unique integer label. An individual record is constructed by using the fixed part alone or by joining the fixed part with one of the variable parts.

When a host language program creates a new variable-format record, it supplies an integer value indicating the type of record being created. This integer must match one of the integer labels associated with a variable part or it must be zero (0). A zero (0) indicates that the record contains the fixed part only. This integer value is automatically stored in the record type item. When a record is retrieved from the database, the record type can be tested to determine the type of variable-format record found.

The following diagram illustrates the syntax for declaring record type items:

<record type item>

──<record type item name>─┬───────────┬────────────────────────────────►
                          └─<comment>─┘

►─┬─ RECORD TYPE ─┬─ ( <unsigned integer> ) ───────────────────────────┤
  └─ TYPE ────────┘

The following table describes the elements of the syntax diagram:

Option

Description

<record type item name>

A record type item name is an identifier that names the item. The record type item name cannot exceed 30 characters.

<unsigned integer>

The unsigned integer controls the number of variable parts that can be declared. The value of the integer must be at least as large as the largest integer label attached to any variable-format part. The minimum value for the unsigned integer is 1 and the maximum value is 254.

The unsigned integer also controls the size of the record type item. If the unsigned integer is 14 or less, then one 4-bit digit is allocated for the item; otherwise, two 4-bit digits are allocated for it.

Example

The following example illustrates the use of record type items. A value of 0 (zero) in T indicates that the record consists of the fixed part alone. Type 0 (zero) records contain items T and A only. When T contains the value 1, the record contains items T, A, A1, and N1. Similarly, if T contains the value 2, the record contains items T, A, R2, A2, and B2.

D DATA SET
 (
  T RECORD TYPE(2);
  A ALPHA(3) REQUIRED;
 ),
1: (
   A1 ALPHA(12);
   N1 NUMBER(6);
  ),
2: (
   R2 REAL;
   A2 ALPHA(35);
   B2 BOOLEAN;
  );

Restart Data Set Control Items

The first word of every restart data set record is a TRANSACTION COUNT item, which provides a count of the number of times the program has been in transaction state. The counter is initialized to 0 (zero) and incremented at ENDTRANSACTION time after the restart area has been saved in the audit trail.

The first digit of the second word of every restart data set record contains a RESTART TYPE item that identifies the value of the restart record. The RESTART TYPE item occupies two digits, but only the first is used. For information about valid values and descriptions for the RESTART TYPE item, refer to Structure Formats.

The TRANSACTION COUNT and RESTART TYPE items are present in every restart data set record regardless of whether they are explicitly declared. If the items are declared, they are read-only items, and their contents cannot be modified. For a user program to access these items, they must be explicitly declared in the DASDL description.

The following table lists the updates and reorganizations required for certain operations involving the TRANSACTION COUNT item, the RESTART TYPE item, or both:

Operation

Required Update or Reorganization

Addition or deletion from the restart data set record description

A DASDL update, a control file update, a DMSUPPORT library recompilation, and a reorganization of the restart data set

Use of the RESTART TYPE item as a key item in a set (the item becomes an implicitly required item)

A reorganization of the restart data set (location change of the first required item in the data set)

Deletion from the restart data set specification in DASDL

A modification and recompilation of programs that refer to the deleted item (thus avoiding a version error)

The following diagram illustrates the syntax for declaring restart data set control items:

<restart data set control items>

──<restart data set control item name>─┬───────────┬─────────────────►
                                       └─<comment>─┘

►─┬─TRANSACTION COUNT──┬───────────────────────────────────────────────┤
  └ RESTART TYPE ──────┘

Example

The following example declares the TRANSACTION COUNT and RESTART TYPE control items in a restart data set.

RDS RESTART DATA SET
    (TC TRANSACTION COUNT;
     RT RESTART TYPE;
     R-DATA ALPHA (20);
    );

Data Set Control Items

If the EXTENDED attribute is set for a data set, then the first word of every data set record is a TRANSTAMP word and the second word is a Record Serial Number (RSN) item. The Enterprise Database Server system maintains these items.

RSN Item

The RSN is a unique, ever‑increasing number with the following characteristics:

  • The RSN exists within the scope of the data set, taking up one word in the record.

  • The system increments the RSN whenever a record is created in the data set.

  • If a record is deleted, the system does not reuse the RSN value of the deleted record.

  • The RSN can be used to uniquely identify a record within the data set.

  • Internally, the system uses the RSN as a tie breaker for sets and subsets that have the DUPLICATES option set.

  • The RSN item is present in every XE data set record regardless of whether it is explicitly declared.

  • If the item is declared, the RSN item is a read‑only item, and its contents cannot be modified.

  • If a user program is to access the RSN or to use it as a key item in a set or subset, the RSN item must be explicitly declared in the DASDL description.

The following table lists the updates and reorganizations required for certain operations involving the RSN item:

Operation

Required Update or Reorganization

Addition or deletion from the data set record description

A DASDL update, a control file update, and a DMSUPPORT library recompilation

A modification and recompilation of programs that refer to the deleted item (thus avoiding a version error)

Use of the RSN item as a key item in a set (the item becomes an implicitly required item)

A reorganization of the data set (location change of the first required item in the data set)

TRANSTAMP Word

You cannot access or declare the TRANSTAMP word. The system uses this word for more efficient record locking within the XE structures. The TRANSTAMP word is the basis for removing the 50,000 locked record limit for the database. Although there is no create or lock limit for XE structures per transaction, if a transaction involving the creation of many records (approximately 200,000 or more) aborts, the SINGLEABORT operation might fail. If the SINGLEABORT operation fails, a halt/load recovery will successfully recover the database.

The following diagram illustrates the syntax for declaring data set control items:

<data set control items>

──<data set control item name>─────────┬───────────┬───────────────────►
                                       └─<comment>─┘

►─┬─RECORD SERIAL NUMBER──┬─────────────────────────────────────────────┤
  └ RSN ──────────────────┘

Example

The following example uses an RSN item, RSN-I.

D DATA SET
  (A Alpha (10); 
   RSN-I RSN;
 );