Group Items in the INTO Clause – select2.sqb

The program select2.sqb is very similar to select2.sqb. Users will see no difference when they run it. From a developer standpoint, however, the use of the INTO clause is different: the data is placed INTO a group item. This provides a shortcut for you, the programmer. See Host Variables and INTO Clause for information about host variables and the INTO clause.

The select2.sqb program contains the following code:

EXEC SQL
   SELECT
        C_NUMBER, C_FIRST_NAME, C_LAST_NAME,
        C_BIRTHDAY, C_INFO
   INTO :C-RECORD
   FROM CUSTOMER
        WHERE C_NUMBER = :C-NUMBER
END-EXEC.

This instructs the program to take the values of fields in the database table and put these respective values INTO a COBOL group item host variable called :C-RECORD. The host variable is a group item; generated code will have individual fields.

Note: There is a special case when working with group items where the generated code is not broken up into the individual fields. This is the case of a VARCHAR datatype. The structure of the COBOL group item must meet a strict format. Refer to the data type compatibility section of the documentation for your data source for more information.