describe input (SQLDA)

Description

Obtains information about dynamic parameter markers in a prepared dynamic SQL statement and stores that information in a SQLDA structure.

Syntax

exec sql describe input statement_name 
 using descriptor descriptor_name end-exec

Parameters

statement_name

The name of the prepared statement about which you want information. statement_name must identify a prepared statement.

descriptor

Identifies descriptor_name as a SQLDA structure.

descriptor_name

The name of the SQLDA structure that is to store information about the dynamic parameter markers in the prepared statement.

Examples

Example 1

...
...


EXEC SQL BEGIN DECLARE SECTION END-EXEC.
    01      QUERY      PIC X(100).
EXEC SQL END DECLARE SECTION END-EXEC.

    01      din.
        05 SD-SQLN PIC S9(4) COMP.
        05 SD-SQLD PIC S9(4) COMP.
        05 SD-COLUMN OCCURS 3 TIMES.
            10 SD-DATAFMT.
                15 SQL--NM PIC X(132).
                15 SQL--NMLEN PIC S9(9) COMP.
                15 SQL--DATATYPE PIC s9(9) COMP.
                15 SQL--FORMAT PIC S9(9) COMP.
                15 SQL--MAXLENGTH PIC S9(9) COMP.
                15 SQL--SCALE PIC S9(9) COMP.
                15 SQL--PRECISION PIC S9(9) COMP.
                15 SQL--STTUS PIC S9(9) COMP.
                15 SQL--COUNT PIC S9(9) COMP.
                15 SQL--USERTYPE PIC S9(9) COMP.
                15 SQL--LOCALE PIC S9(9) COMP.
            10 SD-SQLDATA PIC S9(9) COMP.
            10 SD-SQLIND  PIC S9(9) COMP.
            10 SD-SQLLEN  PIC S9(9) COMP.
            10 SD-SQLMORE PIC S9(9) COMP.
    01 TMP PIC Z(8)9.

            ...
 
    DISPLAY "ENTER QUERY :"
    ACCEPT QUERY.
 
    EXEC SQL ALLOCATE DESCRIPTOR din WITH MAX 256 END-EXEC.
    EXEC SQL PREPARE dynstmt FROM :QUERY END-EXEC.
    EXEC SQL DECLAR selcursor CURSOR FOR dynstmt END-EXEC.
    EXEC SQL DESCRIBE INPUT dynstmt USING DESCRIPTOR din END-EXEC.
 
    * SD-SQLD contains the number of columns in the query being described
        MOVE SD-SQLD TO TMP.
        DISPLAY "Number of input parameters = ", SD-SQLD.
 
            ...

Usage

Information about the statement is written into the descriptor specified in the using clause. After the get descriptor statement is executed, you can read the information out of the SQLDA structure.

See also

allocate descriptor, deallocate descriptor, describe output, get descriptor, prepare, set descriptor