Was this helpful?
Variable and Type Declarations
This section describes how to declare variables to EQUEL. It provides a general description of declaration sections and a detailed description of the declaration syntax for all data types.
EQUEL Variable Declaration Procedures
Any COBOL language variable an EQUEL statement uses must be made known to the processor so that it can determine the type of the variable. Use two number signs (##) to begin a declaration of a variable in an EQUEL/COBOL program. Begin the signs in the first column position of the line. If the variable is not used in an EQUEL statement, you do not need to use number signs, and the rules in the following sections do not apply.
Declare EQUEL/COBOL variables in the FILE or the STORAGE sections of the DATA DIVISION.
The Declare Statement
The WORKING-STORAGE SECTION for each program block must include the EQUEL statement:
## DECLARE
This statement makes the preprocessor generate a COBOL COPY statement of a file of declarations needed by the Ingres runtime system. You cannot successfully compile an EQUEL/COBOL program unless you include the declare statement in the WORKING-STORAGE SECTION.
Data Item Declaration Syntax
This section describes rules and restrictions for declaring EQUEL/COBOL data items. EQUEL recognizes only a subset of legal COBOL declarations.
The following template is the complete data item declaration format that EQUEL/COBOL accepts:
level-number
             [data-name | FILLER]
             [ REDEFINES data-item]
             [ [ISGLOBAL]
             [ [ISEXTERNAL]
             [ PICTURE [ISpic-string ]
             [ [USAGE [IS]] use-type ]
             [ SIGN clause ]
             [ SYNCHRONIZED clause ]
             [ JUSTIFIED clause ]
             [ BLANK clause ]
             [ VALUE clause ]
             [ OCCURS clause ] .
Syntax Notes:
Data declaration clauses can be in any order, with the following two exceptions:
The data-name or FILLER clause, if given, must immediately follow the level number.
The REDEFINES clause, if given, must immediately follow the data-item or FILLER clause.
The level-number can range from 01 to 49. Level number 77 (for noncontiguous data items) is also valid and the preprocessor regards it as identical to level 01. The EQUEL/COBOL preprocessor does not support levels 66 (which identifies RENAMES items) and 88 (which associates condition names with values).
Follow the COBOL rules for specifying the organization of data when you assign level numbers to your EQUEL data items. Like the COBOL compiler, the preprocessor recognizes that a data item belongs to a record or group if its level number is greater than the record or group level number.
The data-name must begin with an alphabetic character or an underscore, which can be followed by alphanumeric characters, hyphens, and underscores. The word FILLER may appear in place of data-name; however, you cannot explicitly reference a FILLER item in an EQUEL statement. If the data-name or FILLER clause is omitted, FILLER is the default.
The preprocessor accepts but does not use the REDEFINES, GLOBAL, EXTERNAL, SIGN, SYNCHRONIZED, JUSTIFIED, BLANK, and VALUE clauses. Consequently, illegal use of these clauses goes undetected at preprocess time but generates COBOL errors later at compile time. For example, the preprocessor does not check that a GLOBAL clause appears only on an 01 level item, nor that a SIGN clause appears only on a numeric item.
The preprocessor expects a PICTURE clause on the COMP, COMP-3, COMP-5 (UNIX only) and DISPLAY use-types.
Do not use a PICTURE clause on INDEX use-types and on the UNIX COMP-1 and COMP-2 use-types.
Although the preprocessor recognizes all the valid COBOL PICTURE symbols, it only makes use of the type and size information needed for runtime support. It does not, for instance, complain about certain illegal combinations of editing symbols in picture strings. EQUEL accepts PIC as an abbreviation for PICTURE. You must specify the picture string on the same line as the keyword PICTURE.
For a description of the valid use-types for the USAGE clause and their interaction with picture strings, see Data Types.
The preprocessor accepts the OCCURS clause for all data items in the level range 02 through 49. The preprocessor does not use the information in the OCCURS clause, except to note that the item described is an array. If you use an OCCURS clause on level 01, the preprocessor issues an error but generates correct code so that you can compile and link the program.
Reserved Words in Declarations
You cannot declare types or variables with the same name as EQUEL keywords. You can only use them in quoted string constants. All EQUEL keywords are reserved. In addition to EQUEL keywords, the following EQUEL/COBOL keywords are reserved and cannot be used except in quoted string constants.
ASCENDING
BLANK
BY*
CHARACTER
COMP-1
COMP-2
DECLARE
DEPENDING
DESCENDING
DISPLAY*
EXTERNAL
FILLER
PACKED_DECIMAL
PIC
PICTURE
POINTER
REDEFINES
REFERENCE
COMP-3
COMP-4
COMP-5
GLOBAL*
IN*
INDEX*
SEPARATE
SIGN
SYNC
COMP-6
COMP
COMPUTATIONAL-1
COMPUTATIONAL-2
COMPUTATIONAL-3
COMPUTATIONAL-4
COMPUTATIONAL-5
COMPUTATIONAL-6
COMPUTATIONAL
INDEXED
IS*
JUST
JUSTIFIED
KEY*
LEADING
OCCURS
OF*
ON*
SYNCHRONIZED
TIMES
TO
TRAILING
USAGE
VALUE
WHEN
ZERO
The EQUEL preprocessor does not distinguish between uppercase and lowercase in keywords. When it generates COBOL code, it converts any lowercase letters in keywords to uppercase. This rule is true only for keywords. The preprocessor does distinguish between case in program-defined types and variable names.
Variable and type names must be legal COBOL identifiers beginning with an alphabetic character or an underscore.
Last modified date: 01/30/2023