The Embedded SQL COBOL precompiler supports the COBOL language structure syntax for host variables in exec sql statements. For example, for a structure A containing structure B, which in turn contains a fundamental structure data item C, A.B.C is equivalent to C OF B OF A.
White spaces are allowed between the elements and the period (.). It is illegal to mix the two syntaxes, such as C OF A .B . Following is an example of group element referencing:
EXEC SQL BEGIN DECLARE SECTION END-EXEC .
01 AU-IDPIC X(15).
01 GROUP1.
05 GROUP2.
10 LNAME PIC X(40).
10 FNAME PIC X(40).
10 PHONE PIC X(15).
EXEC SQL END DECLARE SECTION END-EXEC.
...
EXEC SQL USE pubs2 END-EXEC.
MOVE "724-80-9391" TO AU-ID.
EXEC SQL SELECT INTO :GROUP1. GROUP2.LNAME,
:GROUP2.FNAME, :PHONE
au_lname, au_fname, phone
FROM authors
WHERE au_id = :AU-ID END-EXEC.
DISPLAY "LAST NAME = ", LNAME.
DISPLAY "FIRST NAME = ", FNAME.
DISPLAY "PHONE # = ", PHONE.
* This SELECT does the same thing. You can use :GROUP1.GROUP2
* which refers to the entire structure, but partially qualified
* names such as :LNAME OF GROUP1 do not work.
EXEC SQL SELECT INTO :GROUP1. GROUP2
au_lname, au_fname, phone
FROM authors
WHERE au_id = :AU-ID END-EXEC.
DISPLAY "----------------------------------------".
DISPLAY "GROUP LISTING FROM ENTIRE STRUCTURES".
DISPLAY "----------------------------------------".
DISPLAY "LAST NAME = ", LNAME.
DISPLAY "FIRST NAME = ", FNAME.
DISPLAY "PHONE # = ", PHONE.
...