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
CREATE OR REPLACE FUNCTION GetSalary
IS
cur_sal NUMBER;
CURSOR cur_salary
IS
SELECT salary
FROM employee;
BEGIN
FETCH STATEMENT cur_salary;
FETCH cur_salary IN cur_sal;
IF cur_salary%NOTFOUND THEN
cur_sal := 100000;
END IF;
CLOSE cur_salary;
END;
The statement CLOSE cur_salary; will be used to close the cursor cur_salary.