open (static cursor)

Description

Opens a previously declared static cursor. This statement can be used to open any static cursor, including one for a stored procedure.

Syntax

exec sql [at connection_name] open cursor_name 
 [row_count = size];

Parameters

cursor_name

The name of the cursor to be opened.

row_count

The number of rows moved in a network roundtrip, not the number fetched into the host variable.

size

The number of rows that are moved at the same time from Adaptive Server to the client. The client buffers the rows until they are fetched by the application. This parameter allows you to tune network efficiency.

Examples

Example 1

exec sql begin declare section;
         char        b_titleid[tidsize+1];
         char        b_title[65];
         char        b_type[typesize+1];
 exec sql end declare section;
         long        sqlcode;
         char        response[10];
                 ...
 exec sql declare titlelist cursor for
     select title_id, substring(title,1,64) 
     from titles where type like :b_type;
     strcpy(b_type, "business");
exec sql open titlelist;
    for (;;)
     exec sql fetch titlelist into :b_titleid,
         :b_title;
         if (sqlcode == 100)
             break;
         printf("   %-8s %s\n", b_titleid, b_title);
         printf("update/delete? ");
         gets(response);
         if (!strncasecmp(response,"u",1))
         {
             printf("enter the new titleid\n>");
             gets(b_titleid);
             exec sql update titles 
                 set title_id = :b_titleid
                 where current of titlelist;
         }
         else if (!strncasecmp(response,"d",1))
         {
             exec sql delete from titles
                 where current of titlelist;
         }
 }
 exec sql close titlelist;

Usage