3. Embedded QUEL for COBOL : COBOL Variables and Data Types : Variable Usage : Record Data Items
 
Share this page                  
Record Data Items
You cannot use a record data item (also referred to as a structure variable) as a single entity in an EQUEL statement. Only elementary data items can communicate with Ingres objects and data.
EQUEL and COBOL use the same syntax to refer to an elementary record item:
elementary-item-name IN OFgroupname IN OFrecordname
Syntax Notes:
The item in the above reference must be a scalar value (numeric, alphanumeric, or alphabetic). You can use any combination of tables and records, but the last referenced item must be a scalar value. Thus, the following references are all legal:
* Element of a record
SAL IN EMPLOYEE
SAL OF EMPLOYEE

* Element of a record as an item of a table
NAME IN PERSON(3)

* Deeply nested element
ELEMENTARY-ITEM OF GROUP3 OF GROUP2 OF REC
The qualification of an elementary item in a record can be elliptical; that is, you do not need to specify all the names in the hierarchy in order to reference the item. You must not, however, use an ambiguous reference that does not clearly qualify an item. For example, assume the following declaration:
##   01   PERSON.
##        02   NAME    PIC X(30).
##        02   AGE     PIC S9(4) USAGE COMP.
##        02   ADDR    PIC X(50).
If you reference the variable "NAME", the preprocessor assumes the elementary item "NAME IN PERSON" is being referred to. However, if there also was the declaration:
##   01   CHILD.
##        02   NAME    PIC X(30).
##        02   PARENT  PIC X(30).
then the reference to "NAME" is ambiguous, because it can refer to either "NAME IN PERSON" or "NAME IN CHILD."
Subscripts, if present, must qualify the data item declared with the OCCURS clause.
The following example uses the record "EMPREC" that contains the elementary data items "ENO", "ENAME," AGE," "JOB," "SALARY," and "DEPT". Assume "EMPREC" was declared to EQUEL in the file "employee.dcl".
DATA DIVISION.
WORKING-STORAGE SECTION.
* See above for description.
##  EXEC SQL INCLUDE "employee.dcl".
##  DECLARE.
PROCEDURE DIVISION.
* Program Code
##    PUTFORM empform
##      (eno = ENO IN EMPREC, ename = ENAME IN EMPREC, 
##       age = AGE IN EMPREC, job = JOB IN EMPREC, 
##       sal = SAL IN EMPREC, dept = DEPT IN EMPREC)
Note that you can write the putform statement without the "EMPREC" qualifications, assuming there were no ambiguous references to the item names:
##    PUTFORM empform
##      (eno = ENO, ename = ENAME, age = AGE,
##       job = JOB, sal = SAL, dept = DEPT)