Pipeline function in oracle

 

--Q: what is pipeline function : 

--Q: What is pipe rows 

--Q: why return is empty ?


drop type country_type force 


---1 create the object type 

create or replace type country_type as OBJECT (

country_id char(2), 

country_name VARCHAR2(100)

);


---2 create the object of that type (step1) 

create or replace type country_table_type as TABLE OF country_type;


---3 create the pipeline function 

create or replace function fun_get_country_details return country_table_type 

PIPELINED  

AS

BEGIN

  FOR i_rec IN (select * from countries) LOOP

    PIPE ROW(country_type(i_rec.country_id,i_rec.country_name));   

  END LOOP;

  RETURN;

END;

/

--4 : query using pipeline function : 

select * from table(fun_get_country_details());


select * from table(fun_get_country_details()) where country_id='IT'

No comments:

Post a Comment