Aliasing from Assigning Cursor Variables to Same Work Area
DECLARE
TYPE empcurtyp IS REF CURSOR;
c1 EMPCURTYP;
c2 EMPCURTYP;
PROCEDURE Get_emp_data
(emp_cv1 IN OUT EMPCURTYP,
emp_cv2 IN OUT EMPCURTYP)
IS
emp_rec employees%ROWTYPE;
BEGIN
OPEN emp_cv1 FOR
SELECT *
FROM employees;
emp_cv2 := emp_cv1;
FETCH emp_cv1 INTO emp_rec; -- fetches first row
FETCH emp_cv1 INTO emp_rec; -- fetches second row
FETCH emp_cv2 INTO emp_rec; -- fetches third row
CLOSE emp_cv1;
dbms_output.Put_line('The following raises an invalid cursor');
-- FETCH emp_cv2 INTO emp_rec; raises invalid cursor when get_emp_data is called
END;
BEGIN
Get_emp_data(c1,c2);
END;
/
OUTPUT:-
The following raises an invalid cursor
PL/SQL procedure successfully completed.
0 comments:
Post a Comment