After a cursor opens, the result sets are returned to the application. Then, the data is fetched and loaded into the application program host variables. Optionally, you can update or delete the data. The fetch and close statements are the same as in static Embedded SQL.
The syntax for the fetch statement is:
exec sql [at connection_name] fetch cursor_nameinto
:host_variable [[indicator]:indicator_variable]
[,:host_variable
[[indicator]:indicator_variable]...];
where:
cursor_name is the name given to the cursor in the declare statement.
There is one C host_variable for each column in the result rows. The variables must have been defined in a declare section, and their datatypes must be compatible with the results returned by the cursor.
The syntax for the close statement is:
exec sql [at connection_name] close cursor_name;
where cursor_name is the name assigned to the cursor in the declare statement.