CLOSE

The CLOSE statement closes a cursor.

Invocation

This statement can be embedded only in a COBOL application program. It is an executable statement that cannot be dynamically prepared.

Syntax

Read syntax diagramSkip visual syntax diagramCLOSEcursor-name

Description

The following keyword parameters are defined for the CLOSE statement:
cursor-name
Identifies the cursor to be closed. The cursor name must identify a declared cursor as explained in DECLARE CURSOR.

Example

A cursor C1 is used to fetch one row at a time into the application program variables HOSPCODE, HOSPNAME, WARDNAME, and PATNAME. Finally, the cursor is closed. If the cursor is reopened, it is again located at the beginning of the rows to be fetched.

EXEC SQLIMS                         
  DECLARE C1 CURSOR FOR DYSQL 
END-EXEC.                        

EXEC SQLIMS                               
   PREPARE DYSQL FROM :SELECT-STATEMENT   
END-EXEC           

EXEC SQLIMS OPEN C1 END-EXEC.
 
EXEC SQLIMS 
  FETCH C1 INTO :HOSPCODE, :HOSPNAME, :WARDNAME, :PATNAME
END-EXEC.
 
IF SQLIMSCODE = 100
PERFORM DATA-NOT-FOUND
ELSE
PERFORM GET-REST-OF-HOSP
UNTIL SQLIMSCODE IS NOT EQUAL TO ZERO.
 
EXEC SQLIMS CLOSE C1 END-EXEC.