Close and Deallocate Cursors

When you are finished with the result set of a cursor, you can close it.

The syntax is:
close cursor_name

Closing a cursor does not change its definition. If you reopen a cursor, SAP ASE creates a new cursor result set using the same query as before. For example:

close authors_crsr
open authors_crsr

You can then fetch from authors_crsr, starting from the beginning of its cursor result set. Any conditions associated with that cursor (such as the number of rows fetched, defined by set cursor rows) remain in effect.

To discard a cursor, deallocate it using:

deallocate cursor cursor_name
Note: In SAP ASE 15.0 and later, the word cursor is optional.

Deallocating a cursor frees any resources associated with it, including the cursor name. You cannot reuse a cursor name until you deallocate it. If you deallocate an open cursor, SAP ASE automatically closes it. Terminating a client connection to a server also closes and deallocates any open cursors.