SQL Programming Manual for Pascal
NonStop SQL Statements and Directives
HP NonStop SQL Programming Manual for Pascal—528614-001
3-29
All Cursors
one call to the procedure where it is defined, you can still use the cursor in subsequent
calls without opening the cursor again.
All Cursors
At run time, the OPEN statement must execute before all FETCH statements, and the
CLOSE statement must execute after all FETCH statements through the cursor. Any
host variable used in a DECLARE CURSOR must be in scope at every instance of an
OPEN or FETCH operation for that cursor.
For more information on cursors, see SELECT on page 3-29.
PREPARE
The PREPARE statement dynamically compiles an SQL statement. A program can
then execute the compiled statement with the EXECUTE statement or, for SELECT
statements, with a cursor. The PREPARE statement associates a statement name with
an SQL statement that is specified as an SQL identifier or host variable.
The PREPARE statement for a given SQL statement must be in the same procedure
as the DESCRIBE INPUT and DESCRIBE statements, the RELEASE statement, and
the EXECUTE or cursor statements (DECLARE CURSOR, OPEN, FETCH, DELETE
WHERE CURRENT, UPDATE WHERE CURRENT, and CLOSE) that are used to
execute the SQL input statement.
RELEASE
The RELEASE statement deallocates space for a dynamic SQL statement that is
prepared from a host variable.
The RELEASE statement must be in the same procedure as the PREPARE statement,
the DESCRIBE INPUT and DESCRIBE statements, and the EXECUTE or cursor
statements (DECLARE CURSOR, OPEN, FETCH, CLOSE) that are used to execute
the SQL statement.
SELECT
The SELECT statement typically retrieves data from one or more tables and views into
host variables. There are two types of SELECT statements that you can use in a
program:
•
A single-row SELECT returns a single row or value.
•
A multirow SELECT returns multiple rows one row at a time.