Previous Topic: Using INCLUDE TABLENext Topic: Referring to Host Variables


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;
DCL  1  BULK_DATA,
     4  BULK_ROW (20),
     5  EMP_ID  FIXED DECIMAL(3),
     5  EMP_NAME  CHAR(30),
     5  DEPT_NAME CHAR(30);
EXEC SQL  END DECLARE SECTION;

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;

Indicator Variables

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

Restrictions

A subscripted data element may not appear within the lowest level of a bulk structure.

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;