Using the INTO Clause
If you associate a SELECT or EXECUTE FUNCTION (or EXECUTE PROCEDURE) statement with a Function cursor, the statement can contain an INTO clause to specify variables to receive the returned values. You can use this method only when you write the SELECT, EXECUTE FUNCTION, or EXECUTE PROCEDURE statement as part of the cursor declaration; see DECLARE statement. In this case, the FETCH statement cannot contain an INTO clause.
EXEC SQL declare ord_date cursor for
select order_num, order_date, po_num
into :o_num, :o_date, :o_po;
EXEC SQL open ord_date;
EXEC SQL fetch next ord_date;
If you prepare a SELECT statement, the SELECT cannot include the INTO clause so you must use the INTO clause of the FETCH statement.
When you create a SELECT statement dynamically, you cannot use an INTO clause because you cannot name host variables in a prepared statement.
If you are certain of the number and data type of values in the projection list, you can use an INTO clause in the FETCH statement. If user input generated the query, however, you might not be certain of the number and data type of values that are being selected. In this case, you must use either a system descriptor or else a pointer to an sqlda structure.