Primitive types

Each EGL primitive type characterizes an area of memory. There are three kinds of primitive types: character, numeric, and datetime.

A variable of type ANY receives the type of the value that is assigned to that variable, as described in the topic ANY.

At declaration time, you specify the primitive type that characterizes each of these values:
Other entities also have a primitive type:

Each primitive type is described on a separate page; and additional details are available on the pages that cover assignments, logical expressions, function invocations, and the call statement.

The sections that follow cover these subjects:

Primitive types at declaration time

Consider the following declarations:
  DataItem
    myItem CHAR(4)
  end
  Record mySerialRecordPart type serialRecord
    {
       fileName="myFile"
    }
    10 name CHAR(20);
    10 address;
      20 street01 CHAR(20);
      20 street02 CHAR(20);
  end
As shown, you must specify a primitive type when you declare these entities:
  • A primitive variable
  • A structure field that is not substructured
You may specify the primitive type of a substructured structure field like address. If you fail to specify the primitive type of such a structure field but you reference the structure field in your code, the product makes these assumptions:
  • The primitive type is assumed to be CHAR, even if the subordinate structure fields are of a different type
  • The length is assumed to be the number of bytes in the subordinate structure fields

Relative efficiency of different numeric types

EGL supports the types DECIMAL, NUM, NUMC, and PACF so you can work more easily with files and databases that are used by legacy applications. It is recommended that you use fields of type BIN in new development or that you use an equivalent integer type (BIGINT, INT, or SMALLINT); calculations are most efficient with fields of those types. You get the greatest efficiency by using fields of type BIN, length 2, and no decimal places (the equivalent of type SMALLINT).

In calculations, assignments, and comparisons, fields that are of type NUM and have no decimal places are more efficient than fields that are of type NUM and have decimal places.

Calculations with fields of types DECIMAL, NUM, NUMC, and PACF are equally efficient.

Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.