select into arrays

Use the select into array method when you know the maximum number of rows that will be returned. If a select into statement attempts to return more rows than the array can hold, the statement returns the maximum number of rows that the smallest array can hold.

Following is an example of selecting into an array:

exec sql begin declare section end-exec
 01 TITLEID-ARRAY PIC X(6) OCCURS 100 TIMES.
 exec sql end declare section end-exec
 ...
 exec sql select title_id into :titleid-array
     from titles end-exec.