Previous Topic: Using INCLUDE TABLENext Topic: Non-bulk Structures and Indicator Arrays


Defining Bulk Structures

A bulk structure is a group element or a record which contains a subordinate array for holding multiple occurrences of input or output values. Bulk structures are used in bulk SELECT, INSERT, and FETCH statements for retrieving or storing multiple rows of data.

Format of a Bulk Structure

A bulk structure consists of three levels:

Bulk Structure Example

The following is an example of a valid bulk structure:

EXEC SQL  BEGIN DECLARE SECTION   END-EXEC.
  02  BULK-DATA.
    04  BULK-ROW OCCURS 20 TIMES.
      05  EMP-ID    PIC 999.
      05  EMP-NAME  PIC X(30).
      05  DEPT-NAME PIC X(30).
EXEC SQL  END DECLARE SECTION    END-EXEC.

Referring to a Bulk Structure

When referring to a bulk structure in a SELECT, FETCH, or INSERT statement, the name of the highest level is used:

EXEC SQL
  FETCH EMPCURS BULK :BULK-DATA
END-EXEC.

Indicator Variables

An indicator variable can be associated with a data item within the structure as follows:

Restrictions

The following COBOL clauses must not appear within a bulk structure definition:

Fillers may appear within the structure; however, their data content is not preserved across a bulk SELECT or FETCH.

Using INCLUDE TABLE

A bulk structure can be defined for a given table by using the INCLUDE TABLE statement with a NUMBER OF ROWS clause. The statement in this example will generate a bulk structure capable of holding 20 entries:

EXEC SQL
  INCLUDE TABLE EMPLOYEE NUMBER OF ROWS 20
END-EXEC.