The SET DESCRIPTOR Statement

To assign values to the system-descriptor-area fields, use the SET DESCRIPTOR statement.

You can use the SET DESCRIPTOR statement to:
  • Set the COUNT field to match the number of items for which you provide descriptions in the system-descriptor area. This value is typically the number of input parameters in a WHERE clause.
    EXEC SQL set descriptor sysdesc COUNT=:hostvar;
  • Set the item-descriptor fields for each column value for which you provide a description.
    EXEC SQL set descriptor sysdesc VALUE :item_num
       DESCRIP_FIELD=:hostvar;

    In this example, item_num is the number of the item descriptor that corresponds to the desired column, and DESCRIP_FIELD is one of the item-descriptor fields that is listed in Fields in each item descriptor of the system-descriptor area.

    Set field values to provide values for input parameters in a WHERE clause (Specify input parameter values) or to modify the contents of an item descriptor field after you use the DESCRIBE...USING SQL DESCRIPTOR statement to fill the system-descriptor area (Put column values into a system-descriptor area).

The database server provides data type constants in the sqltypes.h header file to identify the data type of a column in the TYPE field (and optionally the ITYPE field) of a system-descriptor area. However, you cannot assign a data type constant directly in a SET DESCRIPTOR statement. Instead, assign the constant value to an integer host variable and specify this variable in the SET DESCRIPTOR statement, as follows:
EXEC SQL BEGIN DECLARE SECTION;
   int i;
   
⋮

EXEC SQL END DECLARE SECTION;

⋮

i = SQLINT;
EXEC SQL set descriptor 'desc1' VALUE 1
   TYPE = :i;

For more information about the data type constants, see Determine the data type of a column. For more information about how to set individual system-descriptor fields, see the entry for the SET DESCRIPTOR statement in the HCL OneDB™ Guide to SQL: Syntax.