Locate the INTO clause
The INTO clause names the host variables that are to receive
the data that the database server returns. The INTO clause must appear
in either the SELECT or the FETCH statement. However it cannot appear
in both statements. The following example specifies host variables
in the FETCH statement:
EXEC SQL DECLARE the_item CURSOR FOR
SELECT order_num, item_num, stock_num
FROM items;
EXEC SQL OPEN the_item;
while(SQLCODE == 0)
{
EXEC SQL FETCH the_item INTO :o_num, :i_num, :s_num;
if(SQLCODE == 0)
printf("%d, %d, %d", o_num, i_num, s_num);
}
This form lets you fetch different rows into different locations. For example, you could use this form to fetch successive rows into successive elements of an array.