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

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

This example is a code fragment from the dynsel function in the sample program 4DynSel.pc. The complete source for the sample program is listed in "ESQL-92 Sample Programs."

/*
**  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 ("\n\t 1st col \t\t 2nd col \t\t 3rd col");
               printf ("\n\t ------- \t\t ------- \t\t --------\n\n");
               }  
           printf ("\t %d \t\t\t %d \t\t\t %s \n", 
                   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