SQL/MX 2.x Reference Manual (H06.04+)

Embedded-Only SQL/MX Statements
HP NonStop SQL/MX Reference Manual540440-003
3-38
EXECUTE IMMEDIATE Statement
EXECUTE IMMEDIATE Statement
The EXECUTE IMMEDIATE statement compiles and executes an SQL statement
whose text is contained in a host variable. The SQL statement supplied cannot have
any input or output parameters and must be a preparable statement.
Use EXECUTE IMMEDIATE only in embedded SQL programs in C or COBOL.
SQL-statement-variable
is a value-specification—a host variable with character data type. When
EXECUTE IMMEDIATE executes, the content of the value specification give the
text of the SQL statement to be compiled and executed. The SQL statement
cannot contain parameters or refer to host variables.
Considerations for EXECUTE IMMEDIATE
Parameters
If the statement to be compiled and executed contains input or output parameters, you
must use separate PREPARE and EXECUTE statements.
C Examples of EXECUTE IMMEDIATE
Execute an SQL statement whose text is contained in the host variable named
:statement:
EXEC SQL EXECUTE IMMEDIATE :statement;
COBOL Examples of EXECUTE IMMEDIATE
Execute an SQL statement whose text is contained in the host variable named
:statement:
EXEC SQL EXECUTE IMMEDIATE :statement END-EXEC.
EXECUTE IMMEDIATE SQL-statement-variable
C/COBOL