CLOSE

Name

CLOSE -- Closes a previously defined cursor object.

Synopsis

CLOSE cursor
  

Parameters

cursor

This parameter takes the name of a currently open cursor that you wish to close.

Results

CLOSE

This message is displayed if the cursor is successfully closed.

NOTICE PerformPortalClose: portal "cursor" not found

This error is displayed if the cursor specified is either not declared, or not open.

Description

The CLOSE command closes an open cursor and frees the resources it was using. Cursors should always be closed after they are no longer needed. Once a cursor is closed, further operations are not allowed on it.

NoteCOMMIT and ROLLBACK
 

Executing a COMMIT or ROLLBACK terminate the current transaction, thereby closing all open cursors.

Examples

The following example declares and then closes the cur_publishers cursor.

DECLARE cur_publishers CURSOR FOR SELECT * FROM publishers;
CLOSE cur_publish;