SQL/MX 2.x Reference Manual (H06.04+)

Embedded-Only SQL/MX Statements
HP NonStop SQL/MX Reference Manual540440-003
3-23
DECLARE CURSOR Declaration
See SELECT Statement on page 2-174 for the syntax of query-expression.
cursor-name
is an SQL identifier—the name of the cursor being declared. The name is unique
within the containing module or compilation unit. The maximum length of a cursor
name is 128 characters. See Identifiers on page 6-52.
WITH HOLD | WITHOUT HOLD
specifies whether (WITH) or not (WITHOUT) an application keeps cursors open
across transaction boundaries. The default is WITHOUT HOLD. You can use the
WITH HOLD clause only with Publish/Subscribe.
cursor-specification
is a query expression, an SQL identifier that names a prepared query expression,
or in the case of a dynamic cursor, a host variable containing a query expression. It
is optionally followed by an ORDER BY clause and a FOR READ ONLY or FOR
UPDATE OF clause. See Identifiers on page 6-52.
ORDER BY colname [ASC[ENDING] | DESC[ENDING]]
[,colname [ASC[ENDING] | DESC[ENDING]]]...]
specifies the order in which the rows of the query result are presented to the
application program. The column name must be the name of a column that is
in the select list of query-expression.
If the select list in the cursor specification includes an expression (it is not a
column name), you must use the AS clause to give a name to the expression.
For detailed information, see SELECT Statement on page 2-174.
FOR {READ ONLY | UPDATE [OF colname [,colname]...]}
specifies whether the cursor is FOR READ ONLY (read-only cursors) or FOR
UPDATE OF (updatable cursors). If no column list is specified for an updatable
cursor, the column list includes every column of the result table generated from
the query expression.
Database modifications—both UPDATE and DELETE operations—are not
allowed through read-only cursors. If a column list is specified for an updatable
cursor, the columns named in an UPDATE operation must be included in the
column list.
ext-cursor-name
is a value specification—a character literal or host variable with character data
type. When DECLARE CURSOR executes, the content of the host variable (if
used) gives the name of the cursor.
Pub/Sub