Using listagg to fetch the data requ data
936666Jan 2 2013 — edited Jan 3 2013Declare Column_name Nvarchar2(4000);
p_input number=5;
begin
select listagg(COLUMN_NAME, ',') within group (order by column_id) INTO Column_name
from user_tab_columns where table_name= upper('mytable' ) and column_id<p_input;
dbms_output.put_line(Column_name);
-- Select Column_name from mytable;(need the output to be represented here and fetch the data based on p_input=5 )
end;
dbms_output.put_line
----------------------------
co1,col2,col3,col4,col5
I want this output to represent in another query (Select Column_name from mytable;).
Thanks!