Oracle 12.1
How can I integrate this function into a SQL query (ID is one of the columns in the query) to get the 3 rows returned by the function as 3 columns in the query for each applicable ID?
Sample code below
Any ideas appreciated. Thanks.
CREATE OR REPLACE FUNCTION get_details (
p_id IN INTEGER
)
RETURN apex_t_varchar2
is
l_output apex_t_varchar2 := apex_t_varchar2();
begin
l_output.extend(3);
if (p_id = 1)
then
l_output(1) := 'Apple';
l_output(2) := 'Fruit';
l_output(3) := 'Citrus';
elsif (p_id = 2)
then
l_output(1) := 'Tiger';
l_output(2) := 'Animal';
l_output(3) := 'Wild';
end if;
return l_output;
end get_details;
select * from table(get_details(1))
select * from table(get_details(2))
select
mod(level,2)+1 id
from dual d
connect by level <= 10