Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

pipelined function and type inside of package

marcoDec 15 2011 — edited Dec 15 2011
Hi all,

I'm sorry for bothering, I tried to google my question before asking here...

The question is:
can I compile type inside of the same package as my pipelined function?

I've got sample function in package, everything works fine.
CREATE OR REPLACE PACKAGE ZOO.pkg_cl_risk_eval  AS

FUNCTION sample (p_date date, p_indicatorid number, p_ismodel number) return cl_risk_act pipelined;

END;
/

CREATE OR REPLACE PACKAGE BODY pkg_cl_risk_eval is

FUNCTION sample (p_date date, p_indicatorid number, p_ismodel number) return cl_risk_act pipelined IS
v_obj cl_risk_type := cl_risk_type(NULL,NULL,NULL,NULL);
BEGIN
FOR e IN (
select trunc(sysdate) as adate, 0 as cid, 0 as indicatorid, case when p_ismodel = 0 then 0 else 1 end as value from dual
              )
LOOP
v_obj.adate        := e.adate;
v_obj.cid            := e.cid;
v_obj.indicatorid := e.indicatorid;
v_obj.value        := e.value;
PIPE ROW (v_obj);
END LOOP;
RETURN;
end;

end;
/
Select statement for using function:
select * from table(zoo.pkg_cl_risk_eval.sample(date '2011-09-30',4, 0))
Can I compile type inside of the same package as my pipelined function?
At this moment it is outside of package:
DROP TYPE cl_risk_type FORCE;
CREATE OR REPLACE TYPE cl_risk_type AS OBJECT
( adate date,
  cid   number(10), 
  indicatorid number(5), 
  value number(5)
)
/ 

CREATE OR REPLACE TYPE cl_risk_act AS TABLE OF cl_risk_type
/ 
As far as I can read it from this source it's impossible, but this information can be out of date.
http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:4447489221109

Oracle version: 11g

Upd:
I'm sorry, I'm not attentive... It is possible as shown in answer to my similiar question:
2323335

Edited by: marco on Dec 15, 2011 7:40 AM
This post has been answered by APC on Dec 15 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 12 2012
Added on Dec 15 2011
8 comments
2,077 views