set descriptor

Description

Inserts or updates data in a SQL descriptor.

For a list of possible SQL descriptor datatypes, see Table 9-5.

Syntax

exec sql set descriptor descriptor_name 
 {count = host_variable} | 
 {value item_number {item_name = 
  :host_variable}[,...] end-exec

Parameters

descriptor_name

The name of the SQL descriptor that contains information about the dynamic parameter markers in a prepared statement.

count

The number of dynamic parameter specifications to be described.

host_variable

A host variable defined in a declare section.

item_number

Represents the nth occurrence of either a dynamic parameter marker or a select column.

item_name

Represents the attribute information of either a dynamic parameter marker or a select list column. Table 9-4 lists the values for item_name.

Table 9-4: Values for item_name

Value

Description

data

Value for the dynamic parameter marker or target associated with the specified SQL descriptor. If indicator is negative, this field is undefined.

length

The length, in characters, of the dynamic parameter marker of target for the specified SQL descriptor.

precision

An integer specifying the total number of digits of precision for the CS_NUMERIC variable.

scale

An integer specifying the total number of digits after the decimal point for the CS_NUMERIC variable.

type

The datatype of this column (item number) in the row. For values, see Table 9-5.

Examples

Example 1

 EXEC SQL BEGIN DECLARE SECTION END-EXEC.
           01     TITLE-ID     PIC X(6).
           01     SALES1       PIC S9(9).
           01     SALES2       PIC S9(9).
           01     ROYALTY      PIC S9(9) COMP.
      EXEC SQL END DECLARE SECTION END-EXEC.
 
           ...
 
      EXEC SQL ALLOCATE DESCRIPTOR roy_desc WITH MAX 3 END-EXEC.
      EXEC SQL PREPARE  getroylty FROM "SELECT royalty FROM roysched
         WHERE title_id = ? and lorange <= ?AND hirange > ?" 
      END-EXEC.
 
      MOVE "BU1032" TO TITLE-ID.
      MOVE 1000     TO SALES1.
      MOVE 10           TO SALES2.
 
      EXEC SQL SET DESCRIPTOR roy_desc VALUE 1 DATA = :TITLE-ID END-EXEC.
      EXEC SQL SET DESCRIPTOR roy_desc VALUE 2 DATA = :SALES1   END-EXEC.
      EXEC SQL SET DESCRIPTOR roy_desc VALUE 3 DATA = :SALES2   END-EXEC.
 
      EXEC SQL EXECUTE getroylty INTO :ROYALTY USING SQL
                 DESCRIPTOR roy_desc END-EXEC.
 
      DISPLAY "ROYALTY = ", ROYALTY.

Usage

An Embedded SQL program passes attribute and value information to Client-Library, which holds the data in the specified SQL descriptor until the program issues it a request to execute a statement.

See also

allocate descriptor, describe input, describe output, execute, fetch, get descriptor, open(dynamic cursor)