Progress
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_expression [ 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.
EXAMPLESThis example illustrates static processing of a SELECT statement. This is a code fragment from the
StatSel
function in sample program2StatSel.pc
. The complete source for this sample program is in Appendix A of the Progress Embedded SQL-92 Guide and Reference .
This example is a code fragment from the
DynSel
function in sample program4DynSel.pc
, which illustrates dynamic processing of a SELECT statement. The complete source for this sample program is in Appendix A of the Progress Embedded SQL-92 Guide and Reference .
NOTES
- You must declare a cursor before any OPEN Statement, FETCH Statement, 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 Statement, CLOSE Statement, and FETCH Statement 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 a Single Row" reference entry for descriptions of the ORDER BY Clause and FOR UPDATE Clause.
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, "Query Expressions" in "SQL-92 Language Elements"
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |