function with multi-values

Started by Harry Yaualmost 25 years ago3 messagesgeneral
Jump to latest
#1Harry Yau
harry.yau@regaltronic.com

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

Harry Yau

#2Eric G. Miller
egm2@jps.net
In reply to: Harry Yau (#1)
Re: function with multi-values

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@jps.net>

#3Harry Yau
harry.yau@regaltronic.com
In reply to: Eric G. Miller (#2)
Re: Re: function with multi-values

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.

I think is will be ok for the first method, but I am not really familiar
with pgplsql.
I am wondering is there any complete referrence for pgplsql online.
Thank You

Harry Yau