Skip to Main Content

SQL & PL/SQL

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!

Problem with my aggregate function

542454Aug 14 2012 — edited Aug 16 2012
Hello there,

I tried to build my own string aggregate function but I've a troubles when I'm using it into my query. When I'm using it, it writes ORA904, whereas this idenfifier exists. Do you know what's wrong ?

here my aggregate function :
create or replace FUNCTION aggme (query_in in VARCHAR2) RETURN VARCHAR2 IS
    incoming    varchar2(4000);
    hold_result varchar2(4000);
    c sys_refcursor;
Begin
    open c for query_in;
    loop
        fetch c into incoming;
        exit when c%notfound;
        hold_result := hold_result||','||incoming;
    end loop;
    return ltrim(hold_result,',');
END;
and here my query by using my aggregate function aggme:
select
  RES.LASTNAME as "LASTNAME",
  RES.FIRSTNAME as "FIRSTNAME",
  aggme('select NAME from PATHOLOGY where ID= RES.PATHOLOGY_ID') as "PATHOLOGY"
from
  TBK_RESOURCE RES
This post has been answered by BluShadow on Aug 16 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 13 2012
Added on Aug 14 2012
18 comments
941 views