Prepare Statement; Syntax Description Of Prepare; Considerations For Prepare; Availability Of A Prepared Statement - HP Neoview SQL Reference Manual

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

PREPARE Statement

"Syntax Description of PREPARE"

"Considerations for PREPARE"

"Examples of PREPARE"

The PREPARE statement compiles an SQL statement for later use with the EXECUTE statement
in a Neoview Script session.
You can also use PREPARE to check the syntax of a statement without executing the statement
in a Neoview Script session.
PREPARE statement-name FROM statement
Syntax Description of PREPARE
statement-name
is an SQL identifier that specifies a name to be used for the prepared statement. See
"Identifiers" (page
value. If you specify the name of an existing prepared statement, the new statement overwrites
the previous one. The statement name is case-sensitive.
statement
specifies the SQL statement to prepare.
Considerations for PREPARE

Availability of a Prepared Statement

If a PREPARE statement fails, any subsequent attempt to run EXECUTE on the named statement
fails.
Only the Neoview Script session that executes the PREPARE can run EXECUTE on the prepared
statement. The prepared statement is available for running EXECUTE until you terminate the
Neoview Script session or until you execute another PREPARE statement that uses the same
statement name (successfully or unsuccessfully).
A statement must be compiled by PREPARE before you can run EXECUTE on it. However, after
the statement is compiled, you can run EXECUTE on the statement multiple times without
recompiling the statement.
Examples of PREPARE
Prepare a SELECT statement, checking for syntax errors:
SQL>prepare empsal from
+>select salary from employee
+>where jobcode = 100;
*** ERROR[4082] Table, view or stored procedure NEO.INVENT.EMPLOYEE does not exist or is inaccessible.
*** ERROR[8822] The statement was not prepared.
SQL>
Prepare a SELECT statement with an unnamed parameter (?) and later run EXECUTE on
it:
SQL>prepare findsal from
+>select salary from persnl.employee
+>where jobcode = ?;
--- SQL command prepared.
SQL>execute findsal using 450;
132
SQL Statements
220). The statement name should be a character string and not a numeric

Advertisement

Table of Contents
loading

Table of Contents