By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create or replace package pkg_projection as
function describe(tab in out dbms_tf.table_t, cols varchar2 default null)
return dbms_tf.describe_t
;
end pkg_projection;
/
create or replace package body pkg_projection as
function describe(tab in out dbms_tf.table_t, cols varchar2 default null)
return dbms_tf.describe_t
as
begin
if cols is null then
return null;
end if;
for i in 1..tab.column.count() loop
/*Mark columns to be propagated*/
tab.column(i).pass_through := ',' || upper(cols) || ',' like '%,' || trim(both '"' from upper(tab.column(i).description.name)) || ',%';
end loop;
return null;
end;
end pkg_projection;
/
create or replace function f_projection(tab table, cols varchar2 default null)
return table pipelined
row polymorphic using pkg_projection;
/
select *
from user_errors
create table t(
id,val1,val2
)
as
select level, -level, lpad(level, 3, '0')
from dual
connect by level < 4
3 rows affected
select *
from f_projection(t, 'ID,VAL')
ID |
---|
1 |
2 |
3 |
select *
from f_projection(t, 'ID,VAL2')
ID | VAL2 |
---|---|
1 | 001 |
2 | 002 |
3 | 003 |
select *
from f_projection(t, null)
ID | VAL1 | VAL2 |
---|---|---|
1 | -1 | 001 |
2 | -2 | 002 |
3 | -3 | 003 |