FETCH

Retrieves a row from the cursor's results set and writes the values of the columns in that row to the corresponding host variables (or to addresses specified in the SQLDA data structure).

Syntax:

>>--EXEC SQL--.-------------------.------->
              +-FOR :host_integer-+
             
 >-----.-------------.--FETCH---.-------------.-->
       +-AT db_name--+          +---PREVIOUS--+
                                +---LAST------+
                                +---PRIOR-----+
                                +---FIRST-----+
                                +---NEXT------+ 

 >-----cursor_name---.-------------------------------------.------->
                     +-USING DESCRIPTOR :sqlda_struct------+
                     |       +--------------------------,-+|
                     |       V                            ||  
                     +-INTO--.-:hvar----------------------.+
                             +-:hvar:ivar-----------------+
                             +-:hvar-.-----------.-:ivar--+
                                     +-INDICATOR-+

 >--END EXEC--><

Parameters:

:host_integer A host variable that specifies the maximum number of host array elements processed. Must be declared as PIC S9(4) COMP-5 or PIC S9(9) COMP-5.
AT db_name The name of a database that has been declared using DECLARE DATABASE. This clause is not required, and if omitted, the connection automatically switches to the connection associated with the DECLARE CURSOR statement if different than the current connection, but only for the duration of the statement. Provided for backward compatibility.
cursor_name A previously declared and opened cursor.
:sqlda_struct An SQLDA data structure previously populated by the DESCRIBE statement and containing output value addresses.