The CLOSE CURSOR in Oracle PLSQL is used when we have finished processing the records of the CURSOR.
Syntax to use CLOSE CURSOR in Oracle SQL / PLSQL is:
CLOSE cursor_name;
Let’s understand, how to CLOSE CURSOR from the help of the below Oracle PLSQL function
1 | CREATE OR REPLACE FUNCTION GetSalary |
2 | IS |
3 | cur_sal NUMBER; |
4 | CURSOR cur_salary |
5 | IS |
6 | SELECT salary |
7 | FROM employee; |
8 |
9 | BEGIN |
10 | FETCH STATEMENT cur_salary; |
11 | FETCH cur_salary IN cur_sal; |
12 | IF cur_salary%NOTFOUND THEN |
13 | cur_sal := 100000; |
14 | END IF; |
15 |
16 | CLOSE cur_salary; |
17 | END ; |
The statement CLOSE cur_salary; will be used to close the cursor cur_salary.