Declare a cursor for each select statement that returns multiple rows of data. You must declare the cursor before using it, and you cannot declare it within a declare section.
The syntax for declaring a cursor is:
exec sql declare cursor_name cursor
for select_statement ;
where:
cursor_name identifies the cursor. The name must be unique and have a maximum of 30 characters. The name must begin with a letter of the alphabet or with the symbols “#” or “_”.
select_statement is a select statement that can return multiple rows of data. The syntax for select is the same as that shown in the Adaptive Server Enterprise Reference Manual, except that you cannot use into or compute clauses.