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
v_num_t DBMS_TF.CSTORE_NUM_T;
BEGIN
FOR counter IN 1..3 LOOP
v_num_t(counter) := counter;
END LOOP;
FOR counter IN 1..v_num_t.COUNT LOOP
DBMS_OUTPUT.PUT_LINE('Compile ' || v_num_t(counter));
END LOOP;
RETURN(DBMS_TF.DESCRIBE_T( cstore_num => v_num_t ));
END;
PROCEDURE open IS
v_num_t DBMS_TF.CSTORE_NUM_T;
BEGIN
DBMS_TF.CSTORE_GET(v_num_t);
FOR counter IN 1..v_num_t.COUNT LOOP
DBMS_OUTPUT.PUT_LINE('Open ' || v_num_t(counter));
END LOOP;
END;
PROCEDURE fetch_rows IS
v_num_t DBMS_TF.CSTORE_NUM_T;
BEGIN
DBMS_TF.CSTORE_GET(v_num_t);
FOR counter IN 1..v_num_t.COUNT LOOP
DBMS_OUTPUT.PUT_LINE('Fetch ' || v_num_t(counter));
END LOOP;
END;
PROCEDURE close IS
v_num_t DBMS_TF.CSTORE_NUM_T;
BEGIN
DBMS_TF.CSTORE_GET(v_num_t);
FOR counter IN 1..v_num_t.COUNT LOOP
DBMS_OUTPUT.PUT_LINE('Close ' || v_num_t(counter));
END LOOP;
END;
END;
CREATE OR REPLACE FUNCTION kscope_func(p_tbl IN TABLE )
RETURN TABLE PIPELINED
ROW POLYMORPHIC USING kscope_ptf;
SELECT *
FROM kscope_func(kscope)
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
RETURN NULL;
END;
PROCEDURE open IS
xstore_number NUMBER := 0;
BEGIN
DBMS_TF.XSTORE_SET('X1',1);
DBMS_TF.XSTORE_GET('X1',xstore_number);
DBMS_OUTPUT.PUT_LINE('Open ' || xstore_number);
DBMS_TF.XSTORE_SET('X1',xstore_number + 1);
END;
PROCEDURE fetch_rows IS
xstore_number NUMBER := 0;
BEGIN
DBMS_TF.XSTORE_GET('X1',xstore_number);
DBMS_OUTPUT.PUT_LINE('Fetch ' || xstore_number);
DBMS_TF.XSTORE_SET('X1',xstore_number + 1);
END;
PROCEDURE close IS
xstore_number NUMBER := 0;
BEGIN
DBMS_TF.XSTORE_GET('X1',xstore_number);
DBMS_OUTPUT.PUT_LINE('Close ' || xstore_number);
DBMS_TF.XSTORE_SET('X1',xstore_number + 1);
END;
END;
SELECT *
FROM kscope_func(kscope)