Name: CLOSE Shortest: CLO
Family: Command Category: Loop & Flow Control
Description: Use the CLOSE command to close an open cursor.

Syntax

CLOSE syntax diagram

Options

cursor
Closes a row pointer in a table that was defined with the DECLARE CURSOR command.

About the CLOSE Command

Cursors are pointers to rows in a table, and are defined using the DECLARE CURSOR command. When you no longer want to use the cursor but want to retain it for later use, use the CLOSE command to close the cursor. When you open the cursor again, it is positioned at the beginning of the set of rows defined by the DECLARE CURSOR command.

Use the LIST CURSOR command to list all of the currently defined cursors and whether the cursor is opened or closed.

When you close a cursor, most of the memory taken by the cursor definition is returned. If the DECLARE CURSOR command used any file handles, they are released.

Example

The following command makes the rows defined by the DECLARE CURSOR command as cursor1 unavailable. To use the information defined by cursor1 again, you need to reopen the cursor with the OPEN command.

CLOSE cursor1

For additional examples, see the "DECLARE CURSOR" entry.