Record properties define the characteristics of the data you
store in record elements. You can remove a record property by
adding the NO keyword to the property name. For example, NOARRAY
removes the ARRAY property.
Not all languages or language processors support all CDO
properties. Those properties that are not supported are ignored.
The valid CDO field properties appear below.
1 – ARRAY
Format
[ ROW_MAJOR ]
[ COLUMN_MAJOR ] ARRAY { [ n1: ] n2 } ...
[ ]
1.1 – Parameters
1.1.1 – n1
Specifies the lower bound of the subscript. Replace n1 with a
signed integer or a value expression that translates to a signed
integer. The default value is 1.
1.1.2 – n2
Specifies the upper bound of the subscript. Replace n2 with a
signed integer or a value expression that translates to a signed
integer. This value is greater than or equal to n1.
1.2 – Description
The ARRAY property defines a single- or multidimensional array in
a field or record element.
In multidimensional arrays, ROW_MAJOR declares the rightmost
subscript to be the fastest varying. COLUMN_MAJOR declares the
leftmost subscript to be the fastest varying.
If you do not specify either ROW_MAJOR or COLUMN_MAJOR, the
default is ROW_MAJOR.
1.3 – Examples
1.CDO> DEFINE FIELD SUPPLIER
cont> ARRAY 0:19 1:4
cont> DATATYPE IS TEXT
cont> SIZE IS 30 CHARACTERS.
In this example, the DEFINE RECORD command includes an ARRAY
property that declares 20 instances of the SUPPLIER field
element (from 0 to 19). Each instance is four 30-character
strings.
2.CDO> DEFINE RECORD SUPPLIER_REC
cont> ROW_MAJOR ARRAY 1:20.
cont> END RECORD.
In this example, the DEFINE RECORD command includes an ARRAY
property that creates the SUPPLIER_REC record element as an
array.
3.CDO> CHANGE RECORD SUPPLIER_REC.
cont> NOARRAY.
cont> END RECORD.
In this example, the CHANGE RECORD command includes a NOARRAY
property that removes the ARRAY property from the SUPPLIER_REC
record element.
2 – NAME
Format
{ BASIC }
{ COBOL }
NAME FOR { PLI } IS name
{ }
{ RPG }
2.1 – Parameters
2.1.1 – name
Specifies a language-specific name for a field or record element.
2.2 – Description
The NAME property declares a language-specific name for a field
or record element.
This name must be a valid name for the specified language or
language processor. CDO does not check the validity of the name
that you specify.
Once you have assigned a language-specific name to an element,
the specific language no longer recognizes the element's original
name.
You can assign only one language-specific name per language to an
element.
CAUTION
Be careful when you use the NAME field property because it
allows you to assign completely different names to the same
field or record element. Choose a language-specific name
that is similar to the element's directory or processing
name to avoid confusion.
2.3 – Examples
CDO> DEFINE FIELD ORDER_NUMBER
cont> DATATYPE IS UNSIGNED NUMERIC
cont> SIZE IS 10 DIGITS
cont> NAME FOR COBOL IS ORDER-NUMBER.
In this example, the NAME property assigns a language-specific
processing name to the ORDER_NUMBER field used by COBOL.
3 – OCCURS_DEPENDING
Format
{ TO n2 TIMES DEPENDING ON name1 [ IN name2 ] ... }
OCCURS n1 { TIMES }
{ }
[ INDEXED BY index-name ]
3.1 – Parameters
3.1.1 – n1,_n2
Specifies the range for the number of occurrences. The value of
n1 is greater than or equal to zero. The value of n2 is greater
than or equal to n1.
3.1.2 – name1
Specifies the field element whose value determines the actual
number of occurrences.
3.1.3 – name2
Specifies the element that contains the depending field. This
element is often a record.
3.1.4 – index-name
Specifies the field element that functions as an index.
3.2 – Description
The OCCURS ... DEPENDING record property declares a variable-
length, one-dimensional array.
The actual number of occurrences varies according to the value of
the name1 field element.
An error occurs if name2 does not include the name1 field, or if
name2 specifies an array record element.
You can repeat name2 as many times as necessary to identify the
particular instance of name1. For example, name2 can repeat to
identify a field element within nested record elements:
CDO> DEFINE RECORD RETIREMENT_CHECKS OCCURS 1 TO 2 TIMES
cont> DEPENDING ON ID_NUMBER IN EMPLOYEES
cont> IN MEDICALLY_RETIRED_EMPLOYEES IN RETIRED_EMPLOYEES.
cont> END RECORD.
3.3 – Examples
1.CDO> DEFINE RECORD VACATION_PAY OCCURS 1 TO 2 TIMES
cont> DEPENDING ON EXCESS_VACATION IN EMPLOYEE_BENEFITS.
cont> EMP_SSN.
cont> WEEKLY_SALARY.
cont> END RECORD.
In this example, the OCCURS ... DEPENDING record property
specifies the number of times the VACATION_PAY record element
occurs. The number of occurrences is based on the run-time
value of the tag variable field element, EXCESS_VACATION, which
is part of the EMPLOYEE_BENEFITS record element.
2.CDO> CHANGE RECORD VACATION_PAY
cont> NOOCCURS.
cont> END RECORD.
In this example, the keyword NOOCCURS in the CHANGE RECORD
command removes the OCCURS ... DEPENDING record property from
the VACATION_PAY record element.
3.CDO> DEFINE FIELD MESSAGE_TABLE_IDX DATATYPE IS LONGWORD.
CDO> DEFINE FIELD MESSAGE_TEXT DATATYPE IS TEXT SIZE IS
cont> 256 CHARACTERS.
CDO> DEFINE RECORD MESSAGE_TABLE.
cont> MESSAGE_STRUCT STRUCTURE OCCURS 10 TIMES INDEXED BY
cont> MESSAGE_TABLE_IDX.
cont> MESSAGE_TEXT.
cont> END MESSAGE STRUCTURE.
cont> END MESSAGE_TABLE RECORD.
CDO> DEFINE RECORD MESSAGE_TABLE2.
cont> MESSAGE_STRUCT STRUCTURE OCCURS 1 TO 10 TIMES
cont> DEPENDING ON MESSAGE_TEXT
cont> INDEXED BY MESSAGE_TABLE_IDX.
cont> MESSAGE_TEXT.
cont> END MESSAGE STRUCTURE.
cont> END MESSAGE_TABLE2 RECORD.
CDO> SHOW RECORD MESSAGE_TABLE/FULL
Definition of record MESSAGE_TABLE
| Contains record MESSAGE_STRUCT
| | Occurs 10 indexed by MESSAGE_TABLE_IDX
| | Contains field MESSAGE_TEXT
| | | Datatype text size is 256 characters
CDO> SHOW RECORD MESSAGE_TABLE2/FULL
Definition of record MESSAGE_TABLE2
| Contains record MESSAGE_STRUCT
| | Occurs 1 to 10 depending on MESSAGE_TEXT
indexed by MESSAGE_TABLE_IDX
| | Contains field MESSAGE_TEXT
| | | Datatype text size is 256 characters
In this example, the MESSAGE_TABLE record contains an INDEXED
BY clause. The name of the index field must already be defined.