Progress
Embedded SQL-92
Guide and Reference
DECLARE CURSOR Statement
Associates a cursor with a static query or a prepared dynamic query statement. The query or the prepared statement can have references to host variables.
SYNTAX
cursor_name
A name you assign to the cursor. The name must meet the requirements for an identifier.
query_expr [ ORDER BY clause ] [ FOR UPDATE clause ]
A complete query expression.
prepared_statement_name
The name assigned to a prepared SQL-92 statement in an earlier PREPARE statement.
EXAMPLESThe first example is a code fragment from the
StatSel
function in the sample program 2StatSel.pc. This example illustrates the static processing of a SELECT statement The complete source for the sample program is listed in "ESQL-92 Sample Programs."
This example is a code fragment from the
DynSel
function in sample program 4DynSel.pc. This example illustrates the dynamic processing of a SELECT statement. The complete source for the sample program is listed in "ESQL-92 Sample Programs."
NOTES
- You must declare a cursor before any OPEN, FETCH, or CLOSE statement.
- The scope of the cursor declaration is the entire source file in which it is declared. The operations on the cursor such as OPEN, CLOSE, and FETCH can occur only within the same compilation unit as the cursor declaration.
- The use of a cursor allows the execution of the positioned forms of the UPDATE and DELETE statements.
- If the DECLARE statement corresponds to a static SQL statement with parameter references:
- The DECLARE statement must be executed before each execution of an OPEN statement for the same cursor.
- The DECLARE statement and the OPEN statement that follows must occur within the same transaction within the same task.
- If the statement contains parameter references to automatic variables or function arguments, the DECLARE statement and the following OPEN statement for the same cursor must occur within the same C function.
- See the SELECT Statement for a Single Row reference entry for descriptions of the ORDER BY and FOR UPDATE clauses.
AUTHORIZATION
None. See AUTHORIZATION for the OPEN Statement.
SQL COMPLIANCE
SQL-92. Progress Extension: prepared_statement_name
ENVIRONMENT
Embedded SQL-92 only
RELATED STATEMENTS
PREPARE Statement, OPEN Statement, FETCH Statement, CLOSE Statement, SELECT Statement for a Single Row, Query Expressions
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |