3. Embedded SQL for COBOL : COBOL Data Items and Data Types : Data Types : Record Declarations
 
Share this page                  
Record Declarations
Embedded SQL accepts COBOL record and group declarations. To declare a record, use the following syntax:
01 data-name.
              record-item.
             {record-item.}
where record-item is a group item:
level-number data-name.
              record-item.
             {record-item.}
or an elementary item:
level-number data-name elementary-item-description.
Syntax Notes:
The record must have a level number of 01. Thereafter, the level numbers of record‑items can be 02 through 49. Embedded SQL applies the same rules as the COBOL compiler in using the level numbers to order the groups and elementary items in a record definition into a hierarchical structure.
If you do not specify elementary‑item‑description for a record item, the preprocessor and the COBOL compiler assume that the record item is a group item.
The elementary‑item‑description can consist of any attributes described for data declarations in the Data Item Declaration Syntax section. The preprocessor does not confirm that the different clauses are acceptable for record items.
The OCCURS clause, denoting a COBOL table, may appear on any record item.
Example: Record declaration
01 EMPTABLE.
  02 EMPREC OCCURS 25 TIMES.
      03 ENAME    PIC X(20).
      03 EADDRESS.
         04 ESTREET   PIC X(15).
         04 ECITY     PIC X(12).
         04 ESTATE    PIC X(2).
         04 EZIP      PIC X(5).
      03 ESALARY PIC S9(6) USAGE COMP.