Skip site navigation (1) Skip section navigation (2)

Re: function with multi-values

From: "Eric G(dot) Miller" <egm2(at)jps(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: function with multi-values
Date: 2001-04-28 21:05:19
Message-ID: 20010428140519.A1201@calico.local (view raw or flat)
Thread:
Lists: pgsql-general
On Sat, Apr 28, 2001 at 09:46:44AM +0800, Harry Yau wrote:
> Dear:
>     I wanna create a function that return a multiple rows in to a single
> 
> row.
> example:
> CREATE FUNCTION GETNAME() RETURNS SETOF VARCHAR AS 'SELECT NAME FROM
> TEST;' LANGUAGE 'SQL';
> 
> when i call this function it return:
> ----------
> peter
> susan
> john
> 
> but I wonder is it possible to make it to return something like
> ---------------------
> peter    susan    john
> 
> I have to use this result to print in quick report.
> THANK YOU VERY MUCH

Maybe you want your function to iterate through the records and return a
string of concatenated results?  Or does it need to be a tuple?  To do
so, I think you'd need to use pgplsql.

-- 
Eric G. Miller <egm2(at)jps(dot)net>

In response to

pgsql-general by date

Next:From: Jeff MeeksDate: 2001-04-29 00:42:17
Subject: Joining more than 2 tables
Previous:From: Alfred PerlsteinDate: 2001-04-28 20:43:18
Subject: Re: On the _need_ to vacuum...

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group