5. Embedded QUEL for Ada : Ada Variables and Data Types : Variable and Type Declarations : Simple Variable Declarations
 
Share this page                  
Simple Variable Declarations
An EQUEL/Ada variable declaration has the following syntax:
identifier {, identifier} :
                             [constant]
                             [array (dimensions) of]
                             type_name
                             [type_constraint]
                             [:= initial_value];
Syntax Notes:
1. The identifier must be a legal Ada identifier beginning with an alphabetic character.
2. If the constant clause is specified, the declaration must include an explicit initialization.
3. If the constant clause is specified, the declared variables cannot be targets of Ingres assignments.
4. The dimensions of an array specification are not parsed by the EQUEL preprocessor. Consequently, unconstrained array bounds and multidimensional array bounds will be accepted by the preprocessor. However, an illegal dimension (such as a non-numeric expression) will also be accepted but will cause Ada compiler errors. For example, both of the following declarations are accepted, even though only the first is legal Ada:
## square: array (1..10, 1..10) of Integer;
## bad_array: array ("dimensions") of Float;
5. The type_name must be either an EQUEL/Ada type (see Data Types and Constants) or a type name already declared to EQUEL.
6. The legal type_constraints are described in the next section.
7. The initial_value is not parsed by the preprocessor. Consequently,
any initial value is accepted, even if it may later cause a Ada compiler error. For example, both of the following initializations are accepted, even though only the first is legal Ada:
## rowcount: Integer := 1;
## msgbuf: String(1..100) := 2; 
        -- Incompatible value
You must not use a single quote in an initial value to specify an Ada attribute. EQUEL will treat it as the beginning of a string literal and will generate an error. For example, the following declaration will generate an error:
id: Integer := Integer 'first
## rows, records:Integer range 0..500 := 0;
## was_error:    Boolean;
## min_sal:          constant Float := 15000.00;
## msgbuf:           String(1..100) := (1..100 = ' ');
## operators:  constant array(1..6) of String(1..2)
##         := ("= ", "!=", "< ", "> ", "<=", ">=");