get descriptor

Description

Retrieves attribute information about dynamic parameter markers and select column list attributes and data from a SQL descriptor.

For a list of SQL descriptor datatype codes, see Table 10-5.

Syntax

exec sql get descriptor descriptor_name 
 {:host_variable = count | 
 value item_number :host_variable = item_name
[, :host_variable = item_name]…};

Parameters

descriptor_name

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

host_variable

A variable defined in a declare section.

count

The number of dynamic parameters retrieved.

item_number

A number specifying the nth dynamic parameter marker or select column for which get descriptor retrieves information.

item_name

The name of an attribute to be retrieved. See Table 10-3:

Table 10-3: Valid item_name values

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.

indicator

Value for the indicator parameter associated with the dynamic parameter marker or target.

length

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

name

The name of the specified SQL descriptor containing information about the dynamic parameter markers.

nullable

Equals 0 if the dynamic parameter marker can accept a null value; otherwise, equals 1.

precision

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

returned_length

The length of character types of the values from the select column list.

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 SQL descriptor datatype codes.

Examples

Example 1

exec sql begin declare section;
     int     numcols, colnum, type, intbuf;
     char    charbuf[100];
 exec sql end declare section;
 ...
 exec sql allocate descriptor big_desc 
     with max 1000;
 exec sql prepare dynstmt from "select * from \
     huge_table";
 exec sql execute dynstmt into sql descriptor
     big_desc;
exec sql get descriptor big_desc :numcols = count;
for (colnum = 1; colnum <= numcols; colnum++)
 {
exec sql get descriptor big_desc
 value :colnum :type = type;
if (type == 4)
{
exec sql get descriptor big_desc
 value :colnum :intbuf = data;
/* Display intbuf. */
...
}
else if (type == 1)
{
big_desc
 value :colnum :charbuf = data;
/* Display charbuf. */ 
...
}
 }
 exec sql deallocate descriptor big_desc;
         ...

Usage

See also

describe input, describe output, fetch, set descriptor