FETCH statement

Use the FETCH statement to move a cursor to a new row in the active set and to retrieve the row values from memory.

Use this statement with and with SPL.


  • 1 HCL OneDB™ extension
  • 2 ESQL/C only
Element Description Restrictions Syntax
cursor_id Cursor to retrieve rows Must be open Identifier
cursor_id_var Host variable storing cursor_id Must be character data type Language specific
data_structure Structure as a host variable Must store fetched values Language specific
descriptor System-descriptor area Must have been allocated Quoted String
descriptor_var Host variable storing descriptor Must be allocated Language specific
indicator_var Host variable for return code if output_var can be NULL value See Using Indicator Variables. Language specific
output_var Host variable for fetched value Must store value from row Language specific
position_num Position relative to current row Value 0 fetches current row Literal Number
position_num_var Host variable ( = position_num) Value 0 fetches current row Language specific
row_position Ordinal position in active set Must be an integer >1 Literal Number
row_position_var Host variable ( = row_ position) Must be 1 or greater Language specific
sqlda_pointer Pointer to an sqlda structure Cannot begin with $ nor : See ESQL/C .


Except as noted, sections that follow describe how to use the FETCH statement in routines. For information about the more restricted syntax and semantics of the FETCH statement in SPL routines, see Fetching from Dynamic Cursors in SPL Routines.

How the database server creates, stores, and fetches members of the active set of rows depends on whether the cursor was declared as a sequential cursor or as a scroll cursor. All cursors that the FETCH statement can reference in SPL routines are sequential cursors.

In X/Open mode, if a cursor-direction value (such as NEXT or RELATIVE) is specified, a warning message is issued, indicating that the statement does not conform to X/Open standards.