ALLBASE/SQL Reference Manual (36216-90216)
Chapter 10 371
SQL Statements A - D
DECLARE CURSOR
DECLARE CURSOR
The DECLARE CURSOR statement associates a cursor with a specified SELECT or EXECUTE
PROCEDURE statement.
Scope
Application Programs and Procedures
SQL Syntax
DECLARE
CursorName
[IN
DBEFileSetName
]CURSOR FOR
{ {
QueryExpression
SelectStatementName
}[FOR UPDATE OF {
ColumnName
}[,...]
FOR READ ONLY]
ExecuteProcedureStatement
ExecuteStatementName
}
Parameters
CursorName
is the name assigned to the newly declared cursor. Two cursors in an
application program cannot have the same name. The cursor name must
conform to the SQL syntax rules for a basic name, described in the
"Names" chapter of this manual, and must also conform to the
requirements of the application programming language.
DBEFileSetName
identifies the DBEFileSet in which ALLBASE/SQL is to store the
section associated with the cursor. If not specified, the default
SECTIONSPACE DBEFileSet is used.
QueryExpression
is a static SELECT statement. It determines the rows and columns to
be processed by means of a select cursor. The rows defined by the query
expression when you open the cursor are called the active set of the cursor.
Parentheses are optional.
The BULK and INTO clauses and dynamic parameters are disallowed.
SelectStatementName
is specified when declaring a select cursor for a dynamically
preprocessed SELECT statement. It is the
StatementName
specified in the
related PREPARE statement.
FOR UPDATE OF
ColumnName
specifies the column or columns which may be updated
using this cursor. The order of the column names is not important. The
column(s) to be updated need not appear in the select list of the SELECT
statement. If you use a FOR UPDATE clause, the query expression must
be updatable.
FOR READ ONLY indicates that data is to be read and not updated. Specify this clause
when you preprocess and application using the FIPS 127.1 flagger, and the
cursor you are declaring reads and does not update columns. FOR READ
ONLY assures optimum performance in this case.