Data access with host structures

A host structure is a group of host variables that an SQL statement can refer to by using a single name. When the host language environment allows it, you can use host language statements to define the host structures.

Begin general-use programming interface information.

Assume that your COBOL program includes the following SQL statement:

EXEC SQL
  SELECT EMPNO, FIRSTNME, LASTNAME, DEPT
    INTO :EMPNO, :FIRSTNME, :LASTNAME, :WORKDEPT
    FROM VEMP
    WHERE EMPNO = :EMPID
END-EXEC.

Now assume that you want to avoid listing the host variables in the preceding example.

You can substitute the name of a structure, such as :PEMP, that contains :EMPNO, :FIRSTNME, :LASTNAME, and :DEPT:

EXEC SQL
  SELECT EMPNO, FIRSTNME, LASTNAME, WORKDEPT
    INTO :PEMP
    FROM VEMP
    WHERE EMPNO = :EMPID
END-EXEC.
End general-use programming interface information.

You can declare a host structure in your program. You can also use DCLGEN to generate a COBOL record description, PL/I structure declaration, or C structure declaration that corresponds to the columns of a table.