When you are finished with the result set of a cursor, you can close it using:
close cursor_name
Closing the cursor does not change its definition. If you reopen a cursor, Adaptive Server 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.
For example:
fetch authors_crsr
au_id au_lname au_fname ----------- ------------------- --------------- 341-22-1782 Smith Meander 527-72-3246 Greene Morningstar 648-92-1872 Blotchet-Halls Reginald (3 rows affected)
To discard a cursor, you must deallocate it using:
deallocate cursor cursor_name
Using cursor, as a keyword, is optional in Adaptive Server 15.0 and later.
Deallocating a cursor frees up any resources associated with the cursor, including the cursor name. You cannot reuse a cursor name until you deallocate it. If you deallocate an open cursor, Adaptive Server automatically closes it. Terminating a client connection to a server also closes and deallocates any open cursors.
Copyright © 2005. Sybase Inc. All rights reserved. |