fetch scrollable cursor

Description

Uses a fetch statement to retrieve data through a cursor and assign it to host variables.

Syntax

exec sql [at connect_name] fetch [fetch orientation]cursor_name into : host_variable [[ indicator]: indicator_variable ] [,: host_variable [[ indicator]: indicator_variable ]...]; 

Parameters

host_variable

One host_variable exists for each column in the result rows.

fetch orientation

Specifies the fetch direction of the row to be fetched, if a cursor is scrollable.

Examples

Example 1

/*
** Fetch the first row in cursor resultset
*/
EXEC SQL FETCH FIRST FROM typelist INTO :a_type;
printf("\n%s\n", a_type);

/*
** Fetch the last row in cursor resultset
*/
EXEC SQL FETCH LAST FROM typelist INTO :a_type;
printf("\n%s\n", a_type);

Usage

See also

declare scrollable cursor