Progress
Embedded 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

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

/*
**    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

The user executing this statement must have at least one of the following privileges:

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, positioned DELETE


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