I\'m trying to create a simple stored procedure that stores queried result into one string.
v_string1 varchar2(100);
Select column1
From dual;
Another option using pure SQL that will work before Oracle 11G, although is still limited to 4000 characters for the string.
Select ltrim(max(names), ', ') as names
From (
Select sys_connect_by_path(name, ' ,') as names
From (
Select name, row_number() over (order by name) as rown
From temp_table
)
Start with rown = 1
Connect by rown = prior rown + 1
)
Using SQL Fiddle:
select LISTAGG(name, ',') WITHIN GROUP (ORDER BY 1) AS names
from temp_table