oracleplsqloracle-objects

Access a Method in a PL/SQL Collection of Objects Using a Pipelined function


I created an object type that contains attributes and methods. I access the object with a pipelined function that returns a collection of that object. This that works file, except I can not access any of the methods of the object returned in the collection. I can see the attributes fine.

Is it possible to access a method of a object when using a pipelined function? I am not sure if I misunderstand how pipelined functions work, or I should be using a different methodology.

I am doing this in an attempt to speed up a long-running and memory-intensive process. The goal is using pipelining in parallel to speed everything up and learn some new stuff along the way.

--object
TYPE schema1.cool_object FORCE AS OBJECT
(
-- Attributes
att_pid NUMBER,
att_some_number number,
--method
method function some_number_doubled Return Number.
)
--nested table type of cool_object
TYPE schema1.cool_object_ns IS TABLE OF schema1.cool_object;

--Function takes (weak) ref cursor returns nested table of the object type
function f_pipeline(p_rows SYS_REFCURSOR) Return schema1.cool_object_ns

--Call to pipeline function
SELECT * FROM TABLE (schema1.package1.f_pipeline (CURSOR ( Select pid, some_number from person_table)));

This returns an object with attributes att_pid and att_some_number accessible in the object but, not the methods.


Solution

  • Try

    SELECT t.*, t.some_number_doubled() FROM TABLE (schema1.package1.f_pipeline (CURSOR ( Select pid, some_number from person_table))) t;