function get_id_memo(p_id number) return varchar2 is
v_memo varchar2(2000);
cursor c_id_memo is
select memo from table
where id = p_id;
begin
for c in c_id_memo loop
if v_memo is null then
v_memo := c.memo;
else
v_memo := v_memo||','||c.memo;
end if;
end loop;
return v_memo;
exception when no_data_found then
null;
end get_id_memo;