Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: user-defined group function
Hello,
Thanks for the solution. It does do what I wanted but I am looking
for a more general solution that works on character columns of ANY
tables, not just table table_a, for example:
SQL>SELECT my_group_func(column_name) FROM USER_TABLES WHERE table_name ="SOME_TABLE"
my_group_func(column_name)
Is it possible?
Thanks, Lynx
In article <37DB717E.79634D53_at_netscape.com>,
John Chiu <johnymc_at_netscape.com> wrote:
> (1) create the function as follows:
>
> Create or replace function my_group_func(id number) return varchar2
> as
> cursor cur_tablea(input_id) is
> select name from table_a where id = input_id;
> result varchar2(500);
> -- I use 500 but you can make it bigger as long as
> -- your version of Oracle supports(2000/4000 bytes)
> begin
> for currow in cur_tablea(id) loop
> result := result || currow.name;
> end loop;
> return result;
> end;
> /
> (2) in sqlplus:
>
> select distinct id, my_group_func(id) "Concat" from table_a;
>
> it should come up with what you want.
>
> John Chiu
> johnc_at_relsol.com
> johnymc_at_netscape.net
>
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
Received on Mon Sep 13 1999 - 08:51:05 CDT
![]() |
![]() |