CREATE OR REPLACE PACKAGE kscope_ptf AS
FUNCTION describe (p_tbl IN OUT DBMS_TF.TABLE_T )
RETURN DBMS_TF.DESCRIBE_T;
PROCEDURE open;
PROCEDURE fetch_rows;
PROCEDURE close;
END;
CREATE OR REPLACE PACKAGE BODY kscope_ptf AS
FUNCTION describe (p_tbl IN OUT DBMS_TF.TABLE_T )
RETURN DBMS_TF.DESCRIBE_T IS
BEGIN
FOR counter IN 1..p_tbl.column.count LOOP
p_tbl.column(counter).for_read := TRUE;
END LOOP;
RETURN NULL;
END;
PROCEDURE open IS
BEGIN
DBMS_OUTPUT.PUT_LINE('open');
END;
PROCEDURE fetch_rows IS
v_rowset DBMS_TF.ROW_SET_T;
BEGIN
DBMS_TF.GET_ROW_SET(v_rowset);
DBMS_OUTPUT.PUT_LINE('fetch rows');
DBMS_TF.TRACE(v_rowset);
END;
PROCEDURE close IS
BEGIN
DBMS_OUTPUT.PUT_LINE('close');
END;
END;
CREATE OR REPLACE FUNCTION kscope_func(p_tbl IN TABLE )
RETURN TABLE PIPELINED
TABLE POLYMORPHIC USING kscope_ptf;
SELECT *
FROM kscope_func(kscope PARTITION BY year
ORDER BY year)