The FETCH statement positions the cursor at the start of the first row, takes the values returned by the query, and assigns these values to the appropriate host variables. Each time a FETCH is performed, the cursor moves to the next row of results and again assigns the values to host variables.
EXEC SQL FETCH cursorname INTO :host-variable END-EXEC.
The program select3.sqb contains the following code:
EXEC SQL FETCH COBCUR1 INTO :C_RECORD END-EXEC.
This positions the cursor, COBCUR1, at the beginning of the table of results returned by the query. The values returned by the query are FETCHed and placed INTO the group item host variable :C_RECORD. FETCH, then, is similar to a SELECT or INSERT operation, except that SELECT applies to results that return a single row and FETCH applies to results that return multiple rows.