CREATE OR REPLACE PACKAGE plsql_tab IS
TYPE tab_type IS
TABLE OF scott.emp%rowtype INDEX BY BINARY_INTEGER;
p_tab tab_type;
FUNCTION getptab RETURN tab_type;
END;
/
show errors
CREATE OR REPLACE PACKAGE BODY plsql_tab IS
FUNCTION getptab RETURN tab_type
IS
BEGIN
SELECT
*
BULK COLLECT
INTO p_tab
FROM
scott.emp;
--dbms_output.put_line(p_tab(p_tab.first).ename);
RETURN p_tab;
END getptab;
END plsql_tab;
/
show errors
REM IN SQL:Geht nicht weil Rückgabetype nur in PL/SQL definiert!
SELECT * FROM TABLE(cast(plsql_tab.gettab as ref_type));
SELECT plsql_tab.gettab FROM dual;
REM IN PL/SQL: Geht
DECLARE my_tab plsql_tab.tab_type;
BEGIN my_tab:=plsql_tab.getptab;
END;
/