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

DECLARE cursor_name CURSOR FOR 
  { query_expr  [ ORDER BY clause  ]  [  FOR UPDATE clause  ]
   |  prepared_statement_name
  } ; 

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.

EXAMPLES

The 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."

EXEC SQL WHENEVER SQLERROR GOTO selerr ;
EXEC SQL DECLARE stcur CURSOR FOR  
     SELECT InvTransNum, Qty, OrderNum FROM PUB.InventoryTrans ;
EXEC SQL OPEN stcur ;      
EXEC SQL WHENEVER NOT FOUND GOTO seldone ; 

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."

EXEC SQL WHENEVER SQLERROR GOTO selerr ;
EXEC SQL PREPARE stmtid from :sel_stmt_v ;
EXEC SQL DECLARE dyncur CURSOR FOR stmtid ;
EXEC SQL OPEN dyncur ;            
EXEC SQL WHENEVER NOT FOUND GOTO seldone ; 

NOTES

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