Declare a cursor for each select statement that returns rows of data. You must declare the cursor before using it, and you cannot declare it within a declare section.
exec sql declare cursor_name [cursor sensitivity] [cursor scrollability] cursor for select_statement ;
Identifies the cursor.
Specifies the sensitivity of the cursor.
Specifies the scrollability of the cursor.
A select statement that can return multiple rows of data. The syntax for select is the same as described in the Adaptive Server Enterprise Reference Manual, except that you cannot use into or compute clauses.
EXEC SQL BEGIN DECLARE SECTION;
char username[30];
char password[30];
char a_type[TITLE_STRING+1];
EXEC SQL END DECLARE SECTION;
.....
/*
** Declare an insensitive scrollable cursor against the
** titles table. Open the cursor.
*/
EXEC SQL DECLARE typelist INSENSITIVE SCROLL CURSOR FOR
SELECT DISTINCT title FROM titles;
EXEC SQL OPEN typelist;
cursor_name must be unique and have a maximum of 255 characters.
cursor_name must begin with a letter of the alphabet or with the symbols “#” or “_”.
If cursor sensitivity is declared as semi_sensitive, scrollability is implied. The cursor is semi_sensitive, scrollable, and read-only.
If cursor sensitivity is declared as insensitive, the cursor is insensitive. Scrollability is determined by specifying SCROLL in the declare part. If SCROLL is omitted or NOSCROLL is specified, the cursor is insensitive only and non-scrollable. It is also read-only.
If cursor sensitivity is not specified, the cursor is non-scrollable and read-only.
If cursor scrollability is specified as scroll in the declare statement and sensitivity is not specified, the cursor is insensitive and scrollable. It is also read-only.
If the SCROLL option is omitted or NOSCROLL is specified in cursor scrollability, the cursor is non-scrollable and read-only.
If cursor scrollability is not specified, the cursor is non-scrollable and read-only.
fetch scrollable cursor