Contents IndexCHECKPOINT statement COMMENT statement

User's Guide
   Part VI. SQL Anywhere Reference
     Chapter 43. Watcom-SQL Statements
      CLOSE statement

Function

To close a cursor.

Syntax

     CLOSE cursor-name

Parameters

     cursor-name:    identifier, or host-variable

Usage

Embedded SQL, procedures, triggers, and batches.

The host-variable format is for Embedded SQL only.

Permissions

The cursor must have been previously opened.

Side effects

None.

See also

Description

This statement closes the named cursor.

Examples

The following examples close cursors in Embedded SQL.

     EXEC SQL CLOSE employee_cursor;
     EXEC SQL CLOSE :cursor_var;

The following procedure uses a cursor.

     CREATE PROCEDURE TopCustomer (OUT TopCompany CHAR(35), OUT TopValue INT)
     BEGIN
         DECLARE err_notfound EXCEPTION
             FOR SQLSTATE '02000' ;
         DECLARE curThisCust CURSOR FOR
         SELECT company_name, CAST(     sum(sales_order_items.quantity *
         product.unit_price) AS INTEGER) VALUE
         FROM customer
         LEFT OUTER JOIN sales_order
         LEFT OUTER JOIN sales_order_items
         LEFT OUTER JOIN product
         GROUP BY company_name ;
     
         DECLARE ThisValue INT ;
         DECLARE ThisCompany CHAR(35) ;
         SET TopValue = 0 ;
         OPEN curThisCust ;
         CustomerLoop:
         LOOP
             FETCH NEXT curThisCust
             INTO ThisCompany, ThisValue ;
                 IF SQLSTATE = err_notfound THEN
                     LEAVE CustomerLoop ;
                 END IF ;
                 IF ThisValue > TopValue THEN
                     SET TopValue = ThisValue ;
                     SET TopCompany = ThisCompany ;
                 END IF ;
             END LOOP CustomerLoop ;
         CLOSE curThisCust ;
     END

Contents IndexCHECKPOINT statement COMMENT statement