CDD/Plus Dictionary Data Definition Language Utility — VMS CDD+_4.1A
Additional information available:
ALIGNEDARRAYBASEBITBLANK_WHEN_ZEROBYTE
COLUMN_MAJORCOMPUTED_BY_DATATRIEVECONDITION_NAME
COPY_FIELDDATATYPEDATEDEFAULT_VALUEDESCRIPTION
D_FLOATINGD_FLOATING_COMPLEXEDIT_CODE
EDIT_STRINGEDIT_WORDELEMENTARY_FIELDFIELD_DESCRIPTION_CLAUSE
F_FLOATINGF_FLOATING_COMPLEXG_FLOATING
G_FLOATING_COMPLEXHELPH_FLOATING COMPLEX
INITIAL_VALUEJUSTIFIED_RIGHTLEFT_OVERPUNCHED_NUMERIC
LEFT_SEPARATE_NUMERICLONGWORDNAMEOCCURS_DEPENDING
OCTAWORDPACKED_DECIMALPICTUREPOINTERQUADWORD
QUERY_HEADERQUERY_NAMERIGHT_OVERPUNCHED_NUMERIC
RIGHT_SEPARATE_NUMERICROW_MAJORSCALESIZE
STRUCTURE_FIELDTEXTUNSIGNED_NUMERICUNSPECIFIED
VALID_FOR_DATATRIEVE_IFVARYING_STRINGVIRTUAL_FIELD
WORDZONED_NUMERIC
bit field sizeboundary optionsdatatype optionsfield attribute statement
field description statementfield nameFixed pointFloating pointlower bound
no digitsno fractspath nameradixRecord definitionscale factor
text field sizetext stringunspecified field sizeupper boundVARIANTS field
VARIANTS OF fieldvs field size
bit field size
An unsigned integer indicating the number of bits in the field.
boundary options
Location where field is aligned relative to start of record in ALIGNED clause.
datatype options
The DATATYPE clause allows you several options for describing a field's data type:
Additional information available:
DATEVIRTUAL_FIELDBITUNSPECIFIEDTEXT
VARYING STRINGPOINTER
Floating pointFixed pointDecimal string
DATE
Specifies that the field is a 64-bit VAX standard absolute date data type.
VIRTUAL_FIELD
Specifies that the field is a VAX DATATRIEVE virtual field. No space is allocated for virtual fields in a record. The COMPUTED BY DATATRIEVE clause determines the value of a virtual field at run time. A STRUCTURE field cannot contain the VIRTUAL FIELD datatype.
BIT
Specifies that the field is a bit string. Indicate the number of bits in the field with an unsigned integer.
UNSPECIFIED
Declares that the field is a sequence of 8-bit unsigned bytes. Indicate the number of bytes in the field with an unsigned integer.
TEXT
Specifies that the field is a sequence of 8-bit ASCII bytes. Indicate the number of characters in the field with an unsigned integer. CDDL accepts CHARACTER as a synonym for TEXT.
VARYING STRING
Specifies that the field is a PL/I or PASCAL varying string. Indicate the number of characters in the field with an unsigned integer. CDDL accepts VARYING TEXT as a synonym for VARYING STRING.
POINTER
Specifies that the field contains the address of another field or record definition. In PL/I, for example, POINTER fields are used to access based variables and buffers allocated by the system. Although PL/I does not associate POINTER fields with a specified record structure, other languages do; the optional [TO path-name] lets you connect a POINTER to a structure.
Floating point
Floating point data types represent approximations to quantities in a scientific notation consisting of a signed integer and a fraction. The four floating point data types are the 32-bit F_FLOATING, the 64-bit D_FLOATING, the 64-bit G_FLOATING, and the 128-bit H_FLOATING. In addition, you can use F_FLOATING COMPLEX, D_FLOATING COMPLEX, G_FLOATING COMPLEX, and H_FLOATING COMPLEX to specify ordered pairs of floating point data types representing the real and imaginary components of complex numbers.
Additional information available:
SCALEBASED_FLOATINGD_FLOATING_COMPLEX
F_FLOATINGF_FLOATING_COMPLEXG_FLOATING
G_FLOATING_COMPLEXH_FLOATINGH_FLOATING COMPLEX
SCALE
You can specify a SCALE as an implied exponent. The signed integer must be in the range -128 to 127. The SCALE specification indicates the number of places to shift the decimal point when the field is evaluated. A negative integer indicates a shift of the specified number of places to the left, and a positive integer indicates a shift of the specified number of places to the right.
BASE
You can also specify the radix, or BASE, with an unsigned integer. The BASE indicates the number system to be used when the field is evaluated. The default BASE is 10.
D_FLOATING
Specifies that the field is a 64-bit floating point number with precision to approximately 16 decimal digits.
D_FLOATING_COMPLEX
Specifies that the field consists of two 64-bit floating complex numbers, one for the real component and one for the imaginary. CDDL accepts D_FLOATING_COMPLEX as a synonym for D_FLOATING COMPLEX.
F_FLOATING
Specifies that the field is a 32-bit floating point number with precision to approximately seven decimal digits.
F_FLOATING_COMPLEX
Specifies that the field consists of two 32-bit floating complex numbers, one for the real component and one for the imaginary. CDDL accepts FLOATING_COMPLEX, FLOATING COMPLEX, and F_FLOATING_COMPLEX as synonyms for F_FLOATING COMPLEX.
G_FLOATING
Specifies that the field is an extended range 64-bit floating point number with precision to approximately 15 decimal digits.
G_FLOATING_COMPLEX
Specifies that the field consists of two extended range 64-bit floating complex numbers, one for the real component and one for the imaginary. CDDL accepts G_FLOATING_COMPLEX as a synonym for G_FLOATING COMPLEX.
H_FLOATING
Specifies that the field is an extended range 128-bit floating point number with precision to approximately 33 decimal digits.
H_FLOATING COMPLEX
Specifies that the field consists of two extended range 128-bit floating complex numbers, one for the real component and one for the imaginary. CDDL accepts H_FLOATING_COMPLEX as a synonym for H_FLOATING COMPLEX.
Fixed point
Fixed point data types represent scaled quantities in a binary
format. They can be SIGNED or UNSIGNED.
o You can declare the total number of DIGITS and the number of
those digits that are FRACTIONS. The number of digits must be
greater than 0 and less than 32. The number of fractions must
not be greater than the number of digits. The default number of
fractions is 0.
o You can specify a SCALE as an implied exponent. The signed
integer must be in the range -128 to 127. The SCALE
specification indicates the number of places to shift the decimal
point when the field is evaluated. A negative specification
indicates a shift of the specified number of places to the left,
and a positive specification indicates a shift of the specified
number of places to the right.
When using SCALE, note the following rules:
- The SCALE specification and the FRACTIONS specification both
indicate how many digits in a field are to the right of the
decimal point. There are, however, two important
differences:
- The number of FRACTIONS you can specify is limited to the
number of DIGITS you declare for the data type. With
SCALE, there is no such limitation.
- With SCALE, you can shift the decimal point to the right
and to the left, but with FRACTIONS, you can shift the
decimal point only to the left.
- Use a positive integer in the SCALE specification to move the
decimal point to the right.
- Use a negative integer in the SCALE specification to move the
decimal point to the left.
o You can also specify the radix, or BASE, with an unsigned
integer. The BASE indicates the number system to be used when
the field is evaluated. The default BASE is 10.
Additional information available:
BYTEWORDLONGWORDQUADWORDOCTAWORD
BYTE
Specifies that the field is an 8-bit byte. The BYTE can be SIGNED or UNSIGNED. If there is no sign specification, UNSIGNED is the default.
WORD
Specifies that the field is a 16-bit word. The field can be SIGNED or UNSIGNED. If no sign is specified, UNSIGNED is the default.
LONGWORD
Specifies that the field is a 32-bit longword. The LONGWORD can be SIGNED or UNSIGNED. If no sign is specified, UNSIGNED is the default.
QUADWORD
Specifies that the field is a 64-bit quadword field. The field can be SIGNED or UNSIGNED. If no sign is specified, UNSIGNED is the default.
OCTAWORD
Specifies that the field is a 128-bit octaword field. The field can be SIGNED or UNSIGNED. If no sign is specified, UNSIGNED is the default.
Example
The STRUCTURE field BACK_ORDER contains examples of valid CDDL data
declarations.
BACK_ORDER STRUCTURE.
PRODUCT_NO DATATYPE IS TEXT
SIZE IS 8 CHARACTERS.
DATE_ORDERED DATATYPE IS DATE.
STATUS_CODE DATATYPE IS BYTE.
QUANTITY DATATYPE IS LONGWORD
ALIGNED ON LONGWORD.
SUPPLIER ARRAY 1:4
DATATYPE IS TEXT
SIZE IS 30 CHARACTERS.
UNIT_PRICE DATATYPE IS LONGWORD SCALE -2.
END BACK_ORDER STRUCTURE.
Decimal string
o You must declare the total number of DIGITS in the field. You
can also declare which of those digits are FRACTIONS. The number
of digits must be greater than 0 and less than 32. The number of
fractions must not be greater than the number of digits. The
default number of fractions is 0.
o You can specify a SCALE as an implied exponent. The signed
integer must be in the range -128 to 127. The SCALE
specification indicates the number of places to shift the decimal
point when the field is evaluated. A negative specification
indicates a shift of the specified number of places to the left,
and positive indicates a shift of the specified number of places
to the right.
When using SCALE, note the following rules:
- The SCALE specification and the FRACTIONS specification both
indicate how many digits in a field are to the right of the
decimal point. There are, however, two important
differences:
o The number of FRACTIONS you can specify is limited to the
number of DIGITS you declare for the data type. With
SCALE, there is no such limitation.
o With SCALE, you can shift the decimal point to the right
and to the left, but with FRACTIONS, you can shift the
decimal point only to the left.
- Use a positive integer in the SCALE specification to move the
decimal point to the right.
- Use a negative integer in the SCALE specification to move the
decimal point to the left.
o You can also specify the radix, or BASE, with an unsigned
integer. The BASE indicates the number system to be used when
the field is evaluated. The default BASE is 10.
Additional information available:
PACKED DECIMALUNSIGNED NUMERICZONED NUMERICLEFT SEPARATE NUMERIC
LEFT OVERPUNCHED NUMERICRIGHT SEPARATE NUMERICRIGHT OVERPUNCHED NUMERIC
PACKED DECIMAL
Specifies that the field is a packed decimal numeric field. CDDL accepts PACKED NUMERIC as a synonym for PACKED DECIMAL.
UNSIGNED NUMERIC
Specifies that the field is an unsigned decimal string. You must use the UNSIGNED keyword.
ZONED NUMERIC
Specifies that the field is a VAX ZONED NUMERIC data type. CDDL accepts SIGNED NUMERIC as a synonym for ZONED NUMERIC.
LEFT SEPARATE NUMERIC
Specifies that the field is a left separate signed numeric decimal string. CDDL accepts [SIGNED] NUMERIC LEFT SEPARATE as a synonym for LEFT SEPARATE NUMERIC.
LEFT OVERPUNCHED NUMERIC
Specifies that the field is a left overpunched signed numeric decimal string. CDDL accepts [SIGNED] NUMERIC LEFT OVERPUNCHED as a synonym for LEFT OVERPUNCHED NUMERIC.
RIGHT SEPARATE NUMERIC
Specifies that the field is a right separate signed numeric decimal string. CDDL accepts [SIGNED] NUMERIC RIGHT SEPARATE as a synonym for RIGHT SEPARATE NUMERIC.
RIGHT OVERPUNCHED NUMERIC
Specifies that the field is a right overpunched signed numeric decimal string. CDDL accepts [SIGNED] NUMERIC RIGHT OVERPUNCHED as a synonym for RIGHT OVERPUNCHED NUMERIC.
field attribute statement
In each field attribute statement, you use field attribute clauses to define the fields in a record. CDDL contains generic field attribute clauses and some facility-specific field attribute clauses that are understood by only a particular language.
field description statement
CDDL contains five types of field description statements. You can use an elementary, STRUCTURE, COPY, VARIANTS, or VARIANTS_OF field description statement, but you can use only one field description statement to define a record. STRUCTURE, COPY, VARIANT, and VARIANTS_OF field description statements are subdivided and defined by subordinate field description statements.
field name
The field name you assign can be up to 31 characters from the set A-Z, 0-9, _, and $. The first character must be a letter from A-Z, and the last character can not be _ or $. You can use 8-bit alphabetic characters in field names.
Fixed point
Fixed point data types represent scaled quantities in a binary
format. They can be SIGNED or UNSIGNED.
o You can declare the total number of DIGITS and the number of
those digits that are FRACTIONS. The number of digits must be
greater than 0 and less than 32. The number of fractions must
not be greater than the number of digits. The default number of
fractions is 0.
o You can specify a SCALE as an implied exponent. The signed
integer must be in the range -128 to 127. The SCALE
specification indicates the number of places to shift the decimal
point when the field is evaluated. A negative specification
indicates a shift of the specified number of places to the left,
and a positive specification indicates a shift of the specified
number of places to the right.
When using SCALE, note the following rules:
- The SCALE specification and the FRACTIONS specification have
a similar function. They both indicate how many digits in a
field are to the right of the decimal point. There are,
however, two important differences:
o The number of FRACTIONS you can specify is limited to the
number of DIGITS you declare for the data type. With
SCALE, there is no such limitation.
o With SCALE, you can shift the decimal point to the right
and to the left, but with FRACTIONS, you can shift the
decimal point only to the left.
- Use a positive integer in the SCALE specification to move the
decimal point to the right.
- Use a negative integer in the SCALE specification to move the
decimal point to the left.
o You can also specify the radix, or BASE, with an unsigned
integer. The BASE indicates the number system to be used when
the field is evaluated. The default BASE is 10.
Additional information available:
BYTEWORDLONGWORDQUADWORDOCTAWORD
PACKED DECIMALUNSIGNED NUMERICZONED NUMERICLEFT SEPARATE NUMERIC
LEFT OVERPUNCHED NUMERICRIGHT SEPARATE NUMERICRIGHT OVERPUNCHED NUMERIC
BYTE
Specifies that the field is an 8-bit byte. The BYTE can be SIGNED or UNSIGNED. If there is no sign specification, UNSIGNED is the default.
WORD
Specifies that the field is a 16-bit word. The field can be SIGNED or UNSIGNED. If no sign is specified, UNSIGNED is the default.
LONGWORD
Specifies that the field is a 32-bit longword. The LONGWORD can be SIGNED or UNSIGNED. If no sign is specified, UNSIGNED is the default.
QUADWORD
Specifies that the field is a 64-bit quadword field. The field can be SIGNED or UNSIGNED. If no sign is specified, UNSIGNED is the default.
OCTAWORD
Specifies that the field is a 128-bit octaword field. The field can
be SIGNED or UNSIGNED. If no sign is specified, UNSIGNED is the
default.
1 Decimal_string
o You must declare the total number of DIGITS in the field. You
can also declare which of those digits are FRACTIONS. The number
of digits must be greater than 0 and less than 32. The number of
fractions must not be greater than the number of digits. The
default number of fractions is 0.
o You can specify a SCALE as an implied exponent. The signed
integer must be in the range -128 to 127. The SCALE
specification indicates the number of places to shift the decimal
point when the field is evaluated. A negative specification
indicates a shift of the specified number of places to the left,
and positive indicates a shift of the specified number of places
to the right.
When using SCALE, note the following rules:
- The SCALE specification and the FRACTIONS specification have
a similar function. They both indicate how many digits in a
field are to the right of the decimal point. There are,
however, two important differences:
o The number of FRACTIONS you can specify is limited to the
number of DIGITS you declare for the data type. With
SCALE, there is no such limitation.
o With SCALE, you can shift the decimal point to the right
and to the left, but with FRACTIONS, you can shift the
decimal point only to the left.
- Use a positive integer in the SCALE specification to move the
decimal point to the right.
- Use a negative integer in the SCALE specification to move the
decimal point to the left.
o You can also specify the radix, or BASE, with an unsigned
integer. The BASE indicates the number system to be used when
the field is evaluated. The default BASE is 10.
PACKED DECIMAL
Specifies that the field is a packed decimal numeric field. CDDL accepts PACKED NUMERIC as a synonym for PACKED DECIMAL.
UNSIGNED NUMERIC
Specifies that the field is an unsigned decimal string. You must use the UNSIGNED keyword.
ZONED NUMERIC
Specifies that the field is a VAX ZONED NUMERIC data type. CDDL accepts SIGNED NUMERIC as a synonym for ZONED NUMERIC.
LEFT SEPARATE NUMERIC
Specifies that the field is a left separate signed numeric decimal string. CDDL accepts [SIGNED] NUMERIC LEFT SEPARATE as a synonym for LEFT SEPARATE NUMERIC.
LEFT OVERPUNCHED NUMERIC
Specifies that the field is a left overpunched signed numeric decimal string. CDDL accepts [SIGNED] NUMERIC LEFT OVERPUNCHED as a synonym for LEFT OVERPUNCHED NUMERIC.
RIGHT SEPARATE NUMERIC
Specifies that the field is a right separate signed numeric decimal string. CDDL accepts [SIGNED] NUMERIC RIGHT SEPARATE as a synonym for RIGHT SEPARATE NUMERIC.
RIGHT OVERPUNCHED NUMERIC
Specifies that the field is a right overpunched signed numeric decimal string. CDDL accepts [SIGNED] NUMERIC RIGHT OVERPUNCHED as a synonym for RIGHT OVERPUNCHED NUMERIC.
Floating point
Floating point data types represent approximations to quantities in a scientific notation consisting of a signed integer and a fraction. The four floating point data types are the 32-bit F_FLOATING, the 64-bit D_FLOATING, the 64-bit G_FLOATING, and the 128-bit H_FLOATING. In addition, you can use F_FLOATING COMPLEX, D_FLOATING COMPLEX, G_FLOATING COMPLEX, and H_FLOATING COMPLEX to specify ordered pairs of floating point data types representing the real and imaginary components of complex numbers.
lower bound
Specifies the lower bound of a subscript in an ARRAY field attribute clause. The default value is 1.
no digits
The total number of digits. No_digits must be greater than 0 and less than 32.
no fracts
The number of no_digits that are fractions. No_fracts must not be greater than no_digits. The default no_fracts is 0.
path name
The location of the record definition in the CDD directory hierarchy. The full dictionary path name of a directory, subdictionary, or object consists of the concatenation of the given names of all its ancestors, beginning with CDD$TOP and ending with its given name. Separate each given name from the next with a period. An example of a path_name is CDD$TOP.CORPORATE.ADDRESS_RECORD.
radix
An unsigned integer. Indicates the number system to be used when the field is evaluated. The default radix is 10.
Record definition
The DEFINE RECORD statement begins each record definition in the source file.
Additional information available:
Syntax RulesUsage NotesExample
Syntax Rules
o You must terminate the DEFINE statement and the END statement
with periods.
o The path name can be a full or a relative path specification.
The last given name in the path name is the name you assign to
the new record definition. You can specify an absolute version
number with the path name.
o The given name of the new record definition is a string of up to
31 characters from the set A-Z, 0-9, _, and $. The first
character must be a letter from A-Z, and the last character must
not be _ or $. You can use 8-bit alphabetic characters in path
names.
o Use the optional DESCRIPTION clause to include text in the CDD to
document the record definition. You must use the keyword
DESCRIPTION and the text delimiters /* and */ to insert one or
more lines of text describing the record into the DEFINE
statement.
o The field description statement defines the whole record. You
can use an elementary, STRUCTURE, COPY, VARIANTS, or VARIANTS_OF
field description statement, but you can use only one field
description statement to define a record.
STRUCTURE, COPY, and VARIANT field description statements are
themselves subdivided and defined by subordinate field
description statements.
o If you specify a path name in the END clause, it must match the
path name in the corresponding DEFINE clause.
o If you specify a given name in the END clause, it must be the
given name of the new data definition and match the final given
name in the path specification of the corresponding DEFINE
clause.
Usage Notes
o If the path name contains dictionary directories that do not
exist, the CDD automatically creates them.
o It is not recommended that you include passwords in the DEFINE
statement path name, because passwords included in the source can
be displayed with the DMU LIST/ITEM=SOURCE command. Instead, use
the /PATH qualifier with the compile command if passwords are
required in the path name.
o The only way to assign a password to a record definition is to
use the DMU SET PROTECTION or DMU SET PROTECTION/EDIT command
after you compile the source file. You cannot assign a password
to a record definition by including it in the DEFINE statement.
Example
The following record description defines the dictionary object
SALARY_RECORD in the sample CDD hierarchy. The field description
statement for the record is SALARY STRUCTURE.
DEFINE RECORD CDD$TOP.PERSONNEL.SERVICE.SALARY_RECORD.
SALARY STRUCTURE.
EMPLOYEE_ID DATATYPE IS UNSIGNED NUMERIC
SIZE IS 9 DIGITS.
PAY STRUCTURE.
JOB_CLASS DATATYPE IS UNSIGNED NUMERIC
SIZE IS 3 DIGITS.
INCR_LEVEL DATATYPE IS UNSIGNED NUMERIC
SIZE IS 1 DIGIT.
WEEKLY_SALARY DATATYPE IS UNSIGNED NUMERIC
SIZE IS 6 DIGITS 2 FRACTIONS.
END PAY STRUCTURE.
END SALARY STRUCTURE.
END SALARY_RECORD RECORD.
scale factor
A signed integer specifying the number of places to shift the decimal point when the field is evaluated. A negative scale_factor indicates a shift to the left, and a positive scale_factor indicates a shift to the right. Scale_factor must be in the range -128 to 127.
text field size
An unsigned integer indicating the number of characters in the field.
text string
Represents text in strings of contiguous 8-bit bytes.
unspecified field size
An unsigned integer indicating the number of bytes in the field.
upper bound
Specifies the upper bound of a subscript in an ARRAY field attribute clause. Its value must be greater than or equal to that of the lower bound.
VARIANTS field
Defines two or more logical views of the same portion of a record definition. The VARIANTS statement functions like the REDEFINES clause in VAX COBOL and VAX DATATRIEVE.
Additional information available:
ParameterSyntax RuleUsage NotesExample
Parameter
variant
A definition of the field characteristics for each subordinate
field of each VARIANT.
Syntax Rule
The VARIANTS, VARIANT, and END statements all must end with periods.
Usage Notes
o Each VARIANT begins on the same byte in the record, subject to
individual alignment options. The length of the longest VARIANT
in the collection determines the overall length of the VARIANTS
field description.
o Be sure that the VARIANTS collection you define conforms to the
requirements of the language or language processor that will
access the record definition.
o VAX DATATRIEVE requires each VARIANT to contain a STRUCTURE field
description statement at the top of the VARIANT.
Example
The following example contains three VARIANT logical views of the
same record. In an application program, you can refer to the logical
view IN_STOCK, BACK_ORDER, or OUT_OF_STOCK depending on how you want
to interpret the STOCK field.
STOCK STRUCTURE.
VARIANTS.
VARIANT.
IN_STOCK STRUCTURE.
PRODUCT_NO DATATYPE IS TEXT
SIZE IS 8 CHARACTERS.
DATE_ORDERED DATATYPE IS DATE.
STATUS_CODE DATATYPE IS BYTE.
QUANTITY DATATYPE IS LONGWORD
ALIGNED ON LONGWORD.
LOCATION ARRAY 1:4
DATATYPE IS TEXT
SIZE IS 30 CHARACTERS.
UNIT_PRICE DATATYPE IS LONGWORD SCALE -2.
END IN_STOCK STRUCTURE.
END VARIANT.
VARIANT.
BACK_ORDER STRUCTURE.
PRODUCT_NO DATATYPE IS TEXT
SIZE IS 8 CHARACTERS.
DATE_ORDERED DATATYPE IS DATE.
STATUS_CODE DATATYPE IS BYTE.
QUANTITY DATATYPE IS LONGWORD
ALIGNED ON LONGWORD.
SUPPLIER ARRAY 1:4
DATATYPE IS TEXT
SIZE IS 30 CHARACTERS.
UNIT_PRICE DATATYPE IS LONGWORD
SCALE -2.
END BACK_ORDER STRUCTURE.
END VARIANT.
VARIANT.
OUT_OF_STOCK STRUCTURE.
PRODUCT_NO DATATYPE IS TEXT
SIZE IS 8 CHARACTERS.
DATE_LAST_SOLD DATATYPE IS DATE.
END OUT_OF_STOCK STRUCTURE.
END VARIANT.
END VARIANTS.
END STOCK STRUCTURE.
VARIANTS OF field
Names a tag variable whose value at run time determines which of the VARIANT fields is the current VARIANT.
Additional information available:
ParametersSyntax RulesUsage NotesExample
Parameters
var_field_name
The tag variable field, whose value determines the selection of
the current VARIANT at run time.
low_value, high_value
Values to be compared to the value of the tag variable at run
time to determine the current VARIANT.
field description statement
A definition of the field characteristics for the subordinate
fields of each VARIANT.
Syntax Rules
o The VARIANT field description block can be repeated.
o The tag variable must be an elementary field fixed in the record
and not part of an array, and it must precede the VARIANTS field
description statement. It cannot be an unnamed field.
o You must fully qualify the tag variable's field name if it is not
unique within the record. A fully qualified field name consists
of an elementary field name preceded by the field names of as
many of its direct ancestors as you need to specify the
elementary field uniquely. You must separate each element of a
fully qualified field name from the next with a period.
Once the elementary field name is identified uniquely, you can
omit any remaining ancestors' field names. Furthermore, if the
tag variable's name is not unique within the record, none of the
ancestors in its fully qualified name can be unnamed fields.
o You must include a tag value clause for VARIANT.
o At run time, the values (low_value and high_value...) you specify
are compared to the value of the tag variable to determine the
current VARIANT.
o Tag value specifications must conform to the following
conditions:
- The tag values low_value, high_value... must be legal values
as defined by the tag variable's data type. For example, if
the tag variable is a TEXT field, the tag values must be
quoted literals.
- The values of high_value must be greater than or equal to the
values of low_value in the collating sequence of the data
type.
- The range of values in one VARIANT must not overlap the range
of values in any other VARIANT.
o The compiler ignores commas, but you can use them to make tag
value specifications easier to read.
o The CDDL compiler does not check that the tag values you specify
are legal. If you specify invalid values, you will receive error
messages when you refer to the VARIANT field in an application.
Usage Notes
o The tag value clause specifies a value or set of values for the
tag variable in each VARIANT of a VARIANTS field collection. The
tag variable can then be used at run time to find the current
VARIANT.
o Languages that do not support tag variables ignore the tag value
clause. For more information on language support of CDD record
definitions, refer to the documentation for the language you are
using.
o Each variant begins on the same byte in the record, subject to
individual alignment options. The length of the longest VARIANT
in the collection determines the overall length of the VARIANTS
field description.
o Be sure that the VARIANT collection you define conforms to the
requirements of the language or language processor that will
access the record definition.
o VAX DATATRIEVE requires each VARIANT to contain a STRUCTURE field
description statement at the top of the VARIANT.
Example
In the following example, RECORD_IDENTIFIER is the tag variable. The
value of RECORD_IDENTIFIER at run time determines which VARIANT is
current according to the translation table in the descriptive text.
STOCK STRUCTURE.
/* RECORD_IDENTIFIER determines field type:
S --> In-stock record.
B --> Back-order record.
O --> Out-of-stock record. */
RECORD_IDENTIFIER DATATYPE IS TEXT
SIZE IS 1 CHARACTER.
VARIANTS OF RECORD_IDENTIFIER.
VARIANT VALUE IS "S".
IN_STOCK STRUCTURE.
PRODUCT_NO DATATYPE IS TEXT
SIZE IS 8 CHARACTERS.
DATE_ORDERED DATATYPE IS DATE.
STATUS_CODE DATATYPE IS BYTE.
QUANTITY DATATYPE IS LONGWORD
ALIGNED ON LONGWORD.
LOCATION ARRAY 1:4
DATATYPE IS TEXT
SIZE IS 30 CHARACTERS.
UNIT_PRICE DATATYPE IS LONGWORD SCALE -2.
END IN_STOCK STRUCTURE.
END VARIANT.
VARIANT VALUE IS "B".
BACK_ORDER STRUCTURE.
PRODUCT_NO DATATYPE IS TEXT
SIZE IS 8 CHARACTERS.
DATE_ORDERED DATATYPE IS DATE.
STATUS_CODE DATATYPE IS BYTE.
QUANTITY DATATYPE IS LONGWORD
ALIGNED ON LONGWORD.
SUPPLIER ARRAY 1:4
DATATYPE IS TEXT
SIZE IS 30 CHARACTERS.
UNIT_PRICE DATATYPE IS LONGWORD
SCALE -2.
END BACK_ORDER STRUCTURE.
END VARIANT.
VARIANT VALUE IS "O".
OUT_OF_STOCK STRUCTURE.
PRODUCT_NO DATATYPE IS TEXT
SIZE IS 8 CHARACTERS.
DATE_LAST_SOLD DATATYPE IS DATE.
END OUT_OF_STOCK STRUCTURE.
END VARIANT.
END VARIANTS.
END STOCK STRUCTURE.
vs field size
An unsigned integer indicating the number of characters in the field.