Progress
SQL-92
Guide and Reference


OPEN Statement

Executes a prepared SQL-92 query associated with a cursor and creates a result set composed of the rows that satisfy the query. This set of rows is called the active set.

SYNTAX

OPEN cursor_name 
  [ USING { [ SQL ] DESCRIPTOR structure_name 
    | :host_variable [ [ INDICATOR ] :ind_variable  ] ,  ...  }   ] ; 

cursor_name

An identifier named in an earlier DECLARE CURSOR statement.

USING [ SQL ] DESCRIPTOR structure_name

Directs the SQL engine to create the result set in storage addressed by the identified SQLDA structure.

USING :host_variable [ [ INDICATOR ] :ind_variable ]

Directs the SQL engine to create the result set in storage addressed by host variables.

EXAMPLE

This example is a code fragment from the StatSel function in sample program 2StatSel.pc, which illustrates static processing of a SELECT statement. The complete source for sample program, 2StatSel.pc, is listed in Appendix A of the Progress Embedded SQL-92 Guide and Reference .

/* 
**    5.  Name WHENEVER routine to handle SQLERROR. 
** 
**    6.  DECLARE cursor for the SELECT statement. 
**        NOTE: You must set input parameter values before OPEN CURSOR. 
**        The static query in this program does not have input parameters. 
** 
**    7.  OPEN the cursor. 
**        NOTE: For static statements, if a DECLARE CURSOR 
**              statement contains references to automatic variables, 
**              the OPEN CURSOR statement must be in the same C function. 
** 
**    8.  Name WHENEVER routine to handle NOT FOUND condition. 
*/ 
      
      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 ; 

NOTES

AUTHORIZATION

Must have DBA privilege of SELECT privilege on all the tables and views referenced in the SELECT statement associated with the cursor.

SQL COMPLIANCE

SQL-92. Progress Extension: USING DESCRIPTOR clause

ENVIRONMENT

Embedded SQL-92 only

RELATED STATEMENTS

DECLARE CURSOR Statement, CLOSE Statement, FETCH Statement, positioned UPDATE Statement, positioned DELETE Statement


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