SQL/MX 2.x Reference Manual (G06.24+, H06.03+)
Embedded-Only SQL/MX Statements
HP NonStop SQL/MX Reference Manual—523725-004
3-22
DECLARE CURSOR Declaration
DECLARE CURSOR Declaration
Considerations for DECLARE CURSOR
C Examples of DECLARE CURSOR
COBOL Examples of DECLARE CURSOR
Publish/Subscribe Examples of DECLARE CURSOR
The DECLARE CURSOR declaration or statement specifies a cursor in a host
program. It associates the name of the cursor with a query expression that specifies
the rows to be retrieved. The program uses the cursor to fetch rows from the result
table of the query expression one row at a time.
There are two forms of DECLARE CURSOR—static and dynamic. A static cursor is
associated with an actual query expression—for example, a SELECT statement—and
a dynamic cursor is associated with a statement name. The static form of DECLARE
CURSOR is a declaration, and the dynamic form is an executable statement.
Use DECLARE CURSOR only in embedded SQL programs in C or COBOL.
DECLARE {cursor-name | ext-cursor-name}
CURSOR [WITH HOLD | WITHOUT HOLD]
FOR {cursor-specification
|ext-statement-name
|rowset-clause }
cursor-specification is:
query-expression [order-by-clause] [updatability-clause]
order-by-clause is:
ORDER BY colname [ASC[ENDING] | DESC[ENDING]]
[,colname [ASC[ENDING] | DESC[ENDING]]]...
updatability-clause is:
FOR {READ ONLY | UPDATE [OF colname [,colname]...]}
ext-cursor-name is:
[GLOBAL | LOCAL] value-specification
ext-statement-name is:
value-specification
rowset-clause is:
ROWSET FOR [ INPUT SIZE rowset-size-in]
[ KEY BY index-identifier]
[ INPUT SIZE rowset-size-in,
KEY BY index-identifier]
sql-statement SQL terminator
C/COBOL
Pub/Sub