Progress
Embedded SQL-92
Guide and Reference


Associating a Cursor with a Query

Use the DECLARE CURSOR statement to associate a cursor with a SELECT statement. The DECLARE CURSOR statement declares a cursor by assigning it a name and associating it with a SELECT statement.

This is the syntax for a DECLARE CURSOR statement:

SYNTAX
EXEC SQL
     DECLARE cursor_name CURSOR FOR SELECT ... FROM ... ; 

EXAMPLE

The following code fragment declares the cursor cust_cur for the associated SELECT statement:

EXEC SQL
   DECLARE cust_cur CURSOR FOR
      SELECT last_name, city, state
      FROM customer
      WHERE cust_no = :cust_no_v; 

The DECLARE CURSOR statement is a declarative SQL statement. ESQL cannot interpret a reference to a cursor that has not been declared. You must declare the cursor before invoking any other SQL-92 statement that references the cursor. A cursor declared in one ESQLC source file cannot be referred to in another ESQLC source file. A cursor name used in a DECLARE CURSOR statement must be unique in a program source file.


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095