Help Center/ Data Warehouse Service/ SQL Syntax Reference (9.1.0.x)/ DDL Syntax/ Stored Procedures, Functions, Triggers, and Cursors/ CLOSE
Updated on 2026-05-29 GMT+08:00
CLOSE
Function
CLOSE frees the resources associated with a cursor.
Precautions
- After a cursor is closed, no subsequent operations are allowed on it.
- Cursors that are no longer used should be closed.
- Each non-held open cursor should be implicitly closed after the transaction that created the cursor is terminated with COMMIT or ROLLBACK.
- A holdable cursor is implicitly closed when the transaction that creates the cursor exits through ROLLBACK.
- If the transaction that creates a cursor is committed, the cursor remains open until an explicit CLOSE operation is performed or the client is disconnected.
- DWS does not have an explicit OPEN cursor statement. A cursor opens when you define it with the CURSOR command. You can see all available cursors by querying the pg_cursors system view.
Syntax
1 | CLOSE { cursor_name | ALL }; |
Parameter Description
| Parameter | Description | Value Range |
|---|---|---|
| cursor_name | Specifies the name of the cursor to be closed. | Name of an existing cursor. |
| ALL | Closes all open cursors. | - |
Examples
Close a cursor.
1 | CLOSE cursor1; |
What is your overall rating for this page?
0
1
2
3
4
5
6
7
8
9
10
Very dissatisfiedVery satisfied
Thank you very much for your feedback. We will continue working to improve the documentation.
The system is busy. Please try again later.