Obtains information about dynamic parameter markers in a prepared dynamic SQL statement and stores that information in a SQL descriptor.
For a list of possible SQL descriptor datatype codes, see Table 9-5.
exec sql describe input statement_name using sql descriptor descriptor_name end-exec
The name of the prepared statement about which you want information. statement_name must identify a prepared statement.
Identifies descriptor_name as a SQL descriptor.
The name of the SQL descriptor that is to store information about the dynamic parameter markers in the prepared statement.
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 QUERY PIC X(100).
01 NIN PIC S9(9) COMP.
01 COUNTER PIC S9(9) COMP.
01 COLTYPE PIC S9(9) COMP.
01 COLLEN PIC S9(9) COMP.
EXEC SQL END DECLARE SECTION END-EXEC.
...
EXEC SQL ALLOCATE DESCRIPTOR din WITH MAX 256 END-EXEC.
DISPLAY "ENTER QUERY :"
ACCEPT QUERY.
EXEC SQL PREPARE dynstmt FROM :QUERY END-EXEC.
EXEC SQL DESCRIBE INPUT dynstmt USING
SQL DESCRIPTOR din END-EXEC.
EXEC SQL GET DESCRIPTOR din :NIN = COUNT END-EXEC.
MOVE 1 TO COUNTER.
PERFORM GET-DESC-LOOP UNTIL COUNTER > NIN.
EXEC SQL DEALLOCATE PREPARE dynstmt END-EXEC.
EXEC SQL DEALLOCATE DESCRIPTOR din END-EXEC.
...
GET-DESC-LOOP.
EXEC SQL GET DESCRIPTOR din VALUE
:COUNTER :COLTYPE = TYPE END-EXEC
EXEC SQL GET DESCRIPTOR din VALUE
:COUNTER :COLLEN = LENGTH END-EXEC
DISPLAY "TYPE OF INPUT = ", COLTYPE
DISPLAY "INPUT LENGTH = ", COLLEN
ADD 1 TO COUNTER .
END-GET-DESC-LOOP.
Information about the statement is written into the descriptor provided in the using clause. Use the get descriptor statement after executing the describe input statement to extract information from the descriptor into host variables.
The descriptor must be allocated before the describe input statement can be executed.
allocate descriptor, deallocate descriptor, describe output, get descriptor, prepare, set descriptor