CREATE OR REPLACE PACKAGE cur_pack AS
PROCEDURE cursoroeffne;
PROCEDURE ausgabe;
PROCEDURE cursorzu;
END;
/
CREATE OR REPLACE PACKAGE BODY cur_pack AS
CURSOR c_emp IS
SELECT
*
FROM
scott.emp;
rec_emp c_emp%rowtype;
PROCEDURE cursoroeffne IS
BEGIN
OPEN c_emp;
END;
PROCEDURE ausgabe IS
BEGIN
FOR i IN 1..3 LOOP
IF NOT c_emp%isopen THEN
OPEN c_emp;
END IF;
FETCH c_emp INTO rec_emp;
dbms_output.put_line('Name:' || rec_emp.ename);
dbms_output.new_line;
END LOOP;
END;
PROCEDURE cursorzu IS
BEGIN
CLOSE c_emp;
END;
END;
/
EXEC cur_pack.cursoroeffne;
EXEC cur_pack.ausgabe;
EXEC cur_pack.cursorzu;