Friday, March 9, 2018

PL/SQL - REFCURSOR Return multiple columns and rows

DECLARE
     TYPE ref_emp_cur IS REF CURSOR;
     var_emp_cur ref_emp_cur;
     varr emp%ROWTYPE;
BEGIN
    OPEN var_emp_cur
    FOR select * FROM Emp;
    LOOP
    FETCH  var_emp_cur INTO varr;
    EXIT WHEN var_emp_cur%NOTFOUND;
    dbms_output.put_line(varr.empno||' - '|| varr.ename ||' - '|| varr.sal);
    END LOOP;
   CLOSE var_emp_cur;
END;

No comments:

Post a Comment