When multiple elementary data items combine to form a group of related items they become a group data item. You can use group data items as host variables. Declare group data items in declare sections.
Following is an example of a group item:
01 AUTH-REC.
10 AUTH-NAME PIC X(25).
10 STATE PIC X(25).
10 TOTAL-SALES PIC S9(9) COMP SYNC
Following is an example of selecting into a group item whose data items are host variables:
exec sql select au_lname, salary, tot_sales
from table into :AUTH-REC end-exec
The preceding example has the same effect as the following code:
exec sql select au_lname, salary, tot_sales
from table into :AUTH-NAME, :SALARY, :TOTAL-SALES
Another equivalent example is:
exec sql select au_lname, salary, tot_sales
from table into :AUTH-NAME OF AUTH-REC,
:SALARY OF AUTH-REC, :TOTAL-SALES OF AUTH-REC
Embedded SQL/COBOL also supports C language structure syntax for host variables in exec sql statements. For example, the preceding example could be rewritten as follows:
exec sql select au_lname, salary, tot_sales
from table into :AUTH-REC.AUTH-NAME,
:AUTH-REC.SALARY, :AUTH-REC.TOTAL-SALES
Use SYNC with COMP, COMP-4, COMP-5, and BINARY data items declared within group data items.