Progress
Embedded SQL-92
Guide and Reference


DESCRIBE Statement

Use the DESCRIBE statement to obtain information about a prepared statement. This is an executable statement that can only be embedded in an ESQL program and cannot be dynamically prepared. The DESCRIBE statement can be used to describe INPUT host variables or OUTPUT host variables. This is the syntax for a DESCRIBE statement:

SYNTAX
EXEC SQL
  DESCRIBE BIND VARIABLES FOR statement_name INTO input_sqlda_name;
 
EXEC SQL
  DESCRIBE SELECT LIST FOR statement_name INTO output_sqlda_name; 

Execute the DESCRIBE BIND VARIABLES statement after preparing an SQL statement and before executing the OPEN statement for the cursor. Specify the input SQLDA in the OPEN cursor statement with the USING DESCRIPTOR clause.

This is the syntax for a USING DESCRIPTOR clause in an OPEN cursor statement:

SYNTAX
EXEC SQL
  OPEN cursor_name USING DESCRIPTOR input_sqlda_name ; 

EXAMPLE

The following DESCRIBE statement populates an SQLDA with information from a prepared SQL statement:

EXEC SQL BEGIN DECLARE SECTION ;
     CHAR  stmt_str[256] ;
EXEC SQL END DECLARE SECTION ;
 
struct sqlda *sqldaptr ;
   .
   .
   .
EXEC SQL PREPARE sel_stmt FROM :stmt_str ;
EXEC SQL DECLARE sel_cur CURSOR FOR sel_stmt ;
EXEC SQL OPEN sel_cur ;
 
/*
** Allocate an SQLDA
*/
if (!(sqldaptr = PRO_SQLDA_Allocate(20, 30)))
{
     printf ("Insufficient memory for SQLDA allocation\n") ;
     exit (1) ;
}
 
EXEC SQL
     DESCRIBE SELECT LIST FOR sel_stmt INTO sqldaptr ; 

The sel_stmt is the output of a PREPARE operation on an SQL statement. When the DESCRIBE statement is executed, values are assigned to the variables in the SQLDA as follows:


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095