Reputation: 1
I have a table TB_FT with two columns ID_FT NUMBER(PK) and NM_FT VARCHAR.
Like: ID_FT NM_FT
1 MYFT1
2 MYFT2
I have another table TB_CEL_FT with 2 columns ID_FT NUMBER(FK) and ID_CEL NUMBER
Like: ID_FT ID_CEL
1 10
1 11
2 30
2 31
2 32
I need to create an stored procedure that returns a sys_refcursor like that:
ID_FT CELS
1 10,11
2 30,21,32
I managed to work with the queries and store the result in a TYPE, but I need to find out how to return the result as a SYS_REFCURSOR.
Could you guys help me? TIA Luis
Upvotes: 0
Views: 55
Reputation: 13725
Newer oracle's support listagg. You can use it like this:
select
id_ft,
listagg(id_cel, ',') within group (order by id_cel) cels,
from
table
group by
id_ft
Upvotes: 1