Name
CLOSE CURSOR
Synopsis
The CLOSE CURSOR
command closes a server-side cursor created with a DECLARE
CURSOR
statement. MySQL does not support
server-side cursors, but does support extensive C programming
extensions.
Vendor |
Command |
---|---|
SQL Server |
Supported |
MySQL |
Not supported |
Oracle |
Supported |
PostgreSQL |
Supported |
SQL99 Syntax and Description
CLOSE { cursor_name }
The cursor_name
is the name of the cursor
created with the DECLARE CURSOR
command.
Example
This example from Microsoft SQL Server opens a cursor and fetches all the rows:
DECLARE employee_cursor CURSOR FOR SELECT lname, fname FROM pubs.dbo.authors WHERE lname LIKE 'K%' OPEN employee_cursor FETCH NEXT FROM employee_cursor WHILE @@FETCH_STATUS = 0 BEGIN FETCH NEXT FROM Employee_Cursor END CLOSE employee_cursor DEALLOCATE employee_cursor
Warning
The DEALLOCATE
statement in Microsoft
SQL Server releases the resources and data structures used by the
cursor, but Oracle, PostgreSQL, and MySQL do not use it.
Get SQL in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.