NonStop SQL/MP Reference Manual

Table Of Contents
NonStop SQL/MP Reference Manual142115
E-11
EXECUTE IMMEDIATE Statement
parameter ?T directly for the type LARGEINT field but converts it for the type
TIMESTAMP field.
CREATE TABLE DEMO (DEMOKEY NUMERIC,
JDATE LARGEINT, DTDATE TIMESTAMP, PRIMARY KEY DEMOKEY);
PREPARE MYSTMT FROM
"INSERT INTO DEMO VALUES (?K, ?T, CONVERTTIMESTAMP(?T) )";
EXECUTE MYSTMT USING ?K=1, ?T=CURRENT_TIMESTAMP;
EXECUTE MYSTMT USING ?K=2, ?T=COMPUTE_TIMESTAMP (10/13/93);
The following SQLCI statements set parameter values with the SET PARAM
command but override one of the parameter values with a value in the USING
clause of the EXECUTE statement:
VOLUME PERSNL;
PREPARE NEWJOB FROM "INSERT INTO JOB VALUES (?CODE, ?DESC)";
SET PARAM ?CODE 950, ?DESC "TECHNICIAN";
EXECUTE NEWJOB USING ?DESC = "SR. TECHNICIAN";
The following SQLCI statements use both SET PARAM and the USING clause of
the EXECUTE statement to supply parameters for a prepared SELECT.
Notice that the first two EXECUTE statements use the part number from SET
PARAM and use positional notation to provide a supplier number (the first
parameter) on the EXECUTE. The third EXECUTE uses both positional and named
notation to supply parameter values. The fourth EXECUTE uses the ?PNUM value
from the SET PARAM (which was overridden, but not changed by the using clause
in the third EXECUTE).
PREPARE FINDSUP FROM "SELECT * FROM INVENT.PARTSUPP"
&" WHERE PARTNUM = ?PNUM AND SUPPNUM = ?";
SET PARAM ?PNUM 4103;
EXECUTE FINDSUP USING 6;
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.
EXECUTE IMMEDIATE :host-var