Re: SQLPLUS: how to make results appear in a line fashion

From: Roland Schaar <rschaar_at_gosch.com>
Date: Tue, 27 Jul 1999 10:07:14 +0200
Message-ID: <379D68B2.3C5C2487_at_gosch.com>


One solution ist to write a function with a cursor and then select the function.

Function xxxx is

   cursor c is
     select col2 from joe;
  result varchar2(2000);
  cnt number;
begin

   result := '';
   cnt := 0;
   for rec in c loop

       cnt := cnt +1 ;
       if cnt = 1 then
          result := result || rec.col2:
       else
           result := result || ', '||rec.col2:
       end if;

   end loop;
   return result;
end;

select xxxx from dual;

You will want to pass a parameter to the function.

roland

DI Roland Schaar
Gosch Consulting GmbH

AleX wrote:

> Hi!
>
> I need to have this done.
>
> I'm in sqlplus 8.0.5
>
> I have a query like this:
>
> FLO> select col2 from joe;
>
> COL2
> -----
> 2
> xzc
> ccxc
> cxcx
> xcx
> zxz
>
> 6 rows selected.
>
> Is there a way to make the results appear like this
>
> FLO> select col2 from joe;
>
> COL2
> -----
> 2, xzc, ccxc, cxcx, xcx, zxz
>
> 6 rows selected.
>
> Any help is appreciated!
>
> --
> Alex Shterenberg
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
Received on Tue Jul 27 1999 - 10:07:14 CEST

Original text of this message