Skip to Main Content

Oracle Database Discussions

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!

Using listagg to fetch the data requ data

936666Jan 2 2013 — edited Jan 3 2013
Declare 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!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 31 2013
Added on Jan 2 2013
11 comments
1,581 views