Progress
SQL-92
Guide and Reference


FETCH Statement

Moves the position of the cursor to the next row of the active set and fetches the column values of the current row into the specified host variables.

SYNTAX

FETCH cursor_name 
  { USING SQL DESCRIPTOR structure_name 
    | INTO :host_var_ref [ [ INDICATOR ] :ind_var_ref ] , ... 
  } ; 

cursor_name

A name identified in an earlier DECLARE CURSOR statement and an OPEN CURSOR statement.

USING SQL DESCRIPTOR structure_name

Directs the SQL engine to FETCH data into storage addressed by an SQLDA structure.

INTO :host_var_ref [ [ INDICATOR ] :ind_var_ref ]

Directs the SQL engine to FETCH data into the identified host variables, and to set values in the identified indicator variables.

EXAMPLE

The complete source for sample program 4DynSel.pc is listed in Appendix A of the Progress Embedded SQL-92 Guide and Reference . This example is a code fragment from the dynsel function in that sample program:

/* 
**  One way to limit the number of rows returned is to 
**  set a new value for "j" here. As supplied in the SPORTS200 database, 
**  the PUB.InventoryTrans table contains 75 rows. 
*/  
      j = 100; 
      for (i = 0; i < j; i++) 
           {  
           EXEC SQL FETCH dyncur INTO 
             :int_p1_v, :int_p2_v, :char_p_v ; 
           if (i == 0) 
               { 
               printf (" 1st col  2nd col  3rd col"); 
               printf (" -------  -------  --------"); 
               }   
           printf (" %d  %d  %s ",  
                   int_p1_v, int_p2_v, char_p_v) ;  
           } 

NOTES

AUTHORIZATION

None (See AUTHORIZATION for the OPEN Statement)

SQL COMPLIANCE

SQL-92; Progress Extension: USING DESCRIPTOR clause

ENVIRONMENT

Embedded SQL-92 only

RELATED STATEMENTS

DECLARE CURSOR Statement, OPEN Statement, CLOSE Statement


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