Try OpenEdge Now
skip to main content
SQL Reference
ESQL Reference : Embedded SQL : ESQL elements and statements : EXECUTE
 
EXECUTE
Executes the statement specified in statement_name.

Syntax

EXECUTE statement_name[ USING
{[ SQL ] DESCRIPTOR structure_name|:host_variable
[[ INDICATOR ]:ind_variable] , ...}] ;

Parameters

statement_name
Name of the prepared SQL statement.
structure_name
Name of an SQL descriptor area (SQLDA).

Notes

*A statement must be processed with a PREPARE statement before it can be processed with an EXECUTE statement.
*A prepared statement can be executed multiple times in the same transaction. Typically each call to the EXECUTE statement supplies a different set of host variables.
*If there is no DESCRIPTOR in the USING clause, the EXECUTE statement is restricted to the number of variables specified in the host variable list. The number and type of the variables must be known at compile time. The host variables must be declared in the DECLARE SECTION before they can be used in the USING clause of the EXECUTE statement.
*If there is a DESCRIPTOR in the USING clause, the program can allocate space for the input host variables at run time.

Example

/*
** Process the non-SELECT input statement
** PREPARE the statement
** EXECUTE the prepared statement
** COMMIT WORK
*/
EXEC SQL PREPARE dynstmt FROM :sql_stmt_v ;
EXEC SQL EXECUTE dynstmt ;
EXEC SQL COMMIT WORK ;
* Related statements