5. Embedded QUEL for Ada : Ada Variables and Data Types : Variable and Type Declarations : Enumerated Type Definitions
 
Share this page                  
Enumerated Type Definitions
The syntax of an EQUEL/Ada enumerated type definition is:
(enumerated_literal {enumerated_literal})
In the context of a type declaration, the syntax is:
type identifier is (enumerated_literal {enumerated_literal});
In the context of a subtype declaration, the syntax is:
subtype identifier is enumerated_type_name [range_constraint];
Syntax Notes:
1. There can be at most 1,000 enumerated literals in an enumerated
type declaration. The preprocessor treats all literals and variables declared with this type as integers. Enumerated literals are treated as though they were declared with the constant clause, and therefore they cannot be the targets of Ingres assignments. When an enumerated literal is used with embedded statements, only the ordinal position of the value in relation to the original enumerated list is relevant. When assigning from an enumerated variable or literal, the preprocessor generates:
enumerated_type_name'pos(enumerated_literal)
When assigning from or into an enumerated variable, the preprocessor passes the object by address and assumes that the value being assigned from or into the variable will not raise a runtime constraint error.
2. An enumerated literal can be an identifier or a character literal. EQUEL does not store or process enumerated literals that are character literals.
3. Enumerated literal identifiers must be unique in their scope. EQUEL does not allow the overloading of variables or constants.
4. The range_constraint for enumerated subtypes is treated as a variable range constraint and is not processed. The type information is determined from enumerated_type_name. For example:
## type Table_Field_States is
## (UNDEFINED, NEWROW, UNCHANGED, CHANGED, DELETED);
## subtype Updated_States is Table_Field_States
## range CHANGED..DELETED;
## tbstate: Table_Field_States := UNDEFINED;
5. EQUEL accepts the predefined enumeration type name boolean that contains the two literals FALSE and TRUE.
6. You can use a representation clause for enumerated types. When you do so, however, you should not reference any enumerated literals of that type in the embedded statements. Enumerated literals are interpreted into their integer relative position (pos) and representation clauses invalidate the effect of the pos attribute that the preprocessor generates. The representation clauses should not be preceded by the ## mark.
7. Enumerated variables and literals can only be used to assign to or from Ingres. These objects cannot be used to specify simple numeric objects, such as table field row numbers or sleep statement seconds.