Gets information about the host variables required to store data retrieved from the database or host variables used to pass data to the database.
DESCRIBE …[ USER TYPES ] …[ { ALL | BIND VARIABLES FOR | INPUT | OUTPUT | SELECT LIST FOR } ] …[ { LONG NAMES [ long-name-spec ] | WITH VARIABLE RESULT } ] …[ FOR ] { statement-name | CURSOR cursor-name } …INTO sqlda-name long-name-spec { OWNER.TABLE.COLUMN | TABLE.COLUMN | COLUMN }
The information returned is the same as for a DESCRIBE without the USER TYPES clause, except that the sqlname field holds the name of the user-defined data type, instead of the name of the column.
If DESCRIBE uses the LONG NAMES clause, the sqldata field holds this information.
DESCRIBE uses the indicator variables in the SQLDA to provide additional information. DT_PROCEDURE_IN and DT_PROCEDURE_OUT are bits that are set in the indicator variable when a CALL statement is described. DT_PROCEDURE_IN indicates an IN or INOUT parameter and DT_PROCEDURE_OUT indicates an INOUT or OUT parameter. Procedure RESULT columns has both bits clear. After a DESCRIBE OUTPUT, these bits can be used to distinguish between statements that have result sets (need to use OPEN, FETCH, RESUME, CLOSE) and statements that do not (need to use EXECUTE). DESCRIBE INPUT sets DT_PROCEDURE_IN and DT_PROCEDURE_OUT appropriately only when a bind variable is an argument to a CALL statement; bind variables within an expression that is an argument in a CALL statement sets the bits.
sqlda = alloc_sqlda( 3 ); EXEC SQL DESCRIBE OUTPUT FOR employee_statement INTO sqlda; if( sqlda->sqld > sqlda->sqln ) { actual_size = sqlda->sqld; free_sqlda( sqlda ); sqlda = alloc_sqlda( actual_size ); EXEC SQL DESCRIBE OUTPUT FOR employee_statement INTO sqlda; }
DESCRIBE sets up the named SQLDA to describe either the OUTPUT (equivalently SELECT LIST) or the INPUT (BIND VARIABLES) for the named statement.