NonStop SQL/MP Reference Manual

Table Of Contents
NonStop SQL/MP Reference Manual142115
P-25
Considerations—PREPARE
FROM { "stmt" | 'stmt' }
{ :stmt-var }
specifies the statement to prepare.
{ "stmt" | 'stmt' }
(for SQLCI only) is a DCL, DDL, DML, or DSL statement enclosed in single or
double quotation marks.
:stmt-var
(for programs only) is a host variable of a character data type that contains an SQL
statement. The statement:
Can use parameters as literals if it is a DML statement (See Parameters on
page P-12)
Cannot refer to host variables
Cannot use an INTO clause if it is a SELECT
Cannot be CLOSE, DECLARE CURSOR, DESCRIBE, DESCRIBE INPUT,
EXECUTE, EXECUTE IMMEDIATE, FETCH, OPEN, PREPARE, or
RELEASE
Considerations—PREPARE
Availability of a prepared statement
If a PREPARE statement fails, any subsequent attempt to execute the named
statement fails.
Only the process that executes the PREPARE can execute the associated prepared
statement. The prepared statement is available for execution until the process (the
program or SQLCI session) terminates, executes another PREPARE statement that
uses the same statement name (either successfully or unsuccessfully), or (programs
only) releases the host variable that contains the statement name with a RELEASE
statement.
In programs, the scope of a prepared statement depends partly on the rules of the
host language in which the PREPARE executes. For more information, see the
NonStop SQL/MP programming manual for your host language.
Name resolution in prepared statements
Unless a CONTROL QUERY BIND NAMES AT EXECUTION directive is in
effect when the PREPARE executes, a prepared statement uses defaults and
DEFINEs in effect at the time it is prepared, not the time it executes. (See
CONTROL QUERY Directive
on page C-70 or Name Resolution on page N-2 for
details.)
Number of prepared statements allowed in SQLCI