SQL/MP Reference Manual
HP NonStop SQL/MP Reference Manual—523352-013
E-11
EXECUTE IMMEDIATE Statement
EXECUTE FINDSUP USING 25;
EXECUTE FINDSUP USING 6, ?PNUM = 5504;
EXECUTE FINDSUP USING 8;
EXECUTE IMMEDIATE Statement
EXECUTE IMMEDIATE is a dynamic SQL statement used in a host program to
compile and execute an SQL statement whose text is contained in a host variable.
:host-var
identifies a host variable declared as an alphabetic or alphanumeric data item;
host-var must contain the SQL statement as a string literal.
If the SQL statement is an INSERT statement, the statement cannot contain the
RETURNING clause.
The SQL statement must not contain parameters or refer to host variables.
Considerations—EXECUTE IMMEDIATE
You can use EXECUTE IMMEDIATE for any DDL, DML, or DCL, or DSL
statement, except OPEN, CLOSE, and SELECT. (Use a cursor to process a
SELECT statement.)
If the program declares an SQLSA, EXECUTE IMMEDIATE does not return
execution statistics as described under INCLUDE SQLSA. EXECUTE IMMEDIATE
does not return compilation statistics.
Example—EXECUTE IMMEDIATE
This SQL statement from a C program executes an SQL statement whose text is
contained in the host variable named :statement:
EXEC SQL EXECUTE IMMEDIATE :statement;
EXECUTE IMMEDIATE :host-var