A host structure array is a named set of host variables that is defined in the program's Data Division and has an OCCURS clause.
Host structure arrays have a maximum of two levels, even though the host structure can occur within a multiple level structure. A varying-length string requires another level, level 49. A host structure array name can be a group name whose subordinate levels name basic data items.
In these examples, the following are true:
01 A-STRUCT. 02 B-ARRAY OCCURS 10 TIMES. 03 C1-VAR PIC X(20). 03 C2-VAR PIC S9(4).
To retrieve 10 rows from the CORPDATA.DEPARTMENT table, use the following example:
01 TABLE-1. 02 DEPT OCCURS 10 TIMES. 05 DEPTNO PIC X(3). 05 DEPTNAME. 49 DEPTNAME-LEN PIC S9(4) BINARY. 49 DEPTNAME-TEXT PIC X(29). 05 MGRNO PIC X(6). 05 ADMRDEPT PIC X(3). 01 TABLE-2. 02 IND-ARRAY OCCURS 10 TIMES. 05 INDS PIC S9(4) BINARY OCCURS 4 TIMES. .... EXEC SQL DECLARE C1 CURSOR FOR SELECT * FROM CORPDATA.DEPARTMENT END-EXEC. .... EXEC SQL FETCH C1 FOR 10 ROWS INTO :DEPT :IND-ARRAY END-EXEC.