close

Description

Closes an open cursor.

Syntax

exec sql [at connection_name] close cursor_name;

Parameters

cursor_name

The name of the cursor to be closed; that is, the name that you assigned when declaring the cursor.

Examples

Example 1

long SQLCODE;
exec sql begin declare section; 
 CS_CHAR        mlname[40]; 
 CS_CHAR        mfname[20]; 
 CS_CHAR        phone[12]; 
 exec sql end declare section; 
exec sql declare author_list cursor for 
         select au_lname, au_fname, phone 
         from authors; 
exec sql open author_list; 
while (SQLCODE == 0) {
         exec sql fetch author_list into
         :mlname, :mfname, :mphone; 
       if(SQLCODE != 100)
         printf(“%s, %s, %s\n”, mlname, mfname,
             mphone); 
 }
exec sql close author_list; 

Usage

See also

declare cursor, fetch, open, prepare