Re: how to return more than 1 arg with a function ?

From: Richard Huxton <dev(at)archonet(dot)com>
To: Feite Brekeveld <feite(dot)brekeveld(at)osiris-it(dot)nl>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: how to return more than 1 arg with a function ?
Date: 2001-02-17 11:48:08
Message-ID: 3A8E64F8.7345C5CA@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Feite Brekeveld wrote:
>
> I want to return mre than 1 arg
>
> create function func(varchar)
> --> returns var1, var2 ....
> as '
> ...
> '
> language 'sql';
>
> How to deal with the return : The manual says to use SETOF can't figure
> out how that works no examples are given.

Not quite right. SETOF returns many items so you could have:

create function list_ids() returns setof int4 as 'select id from foo;'
language 'sql';

select list_ids();

list_id
-------
1
2
7
12

You can also return a tuple like:

create function whole_row() returns foo as ...

But - that can only be used to feed into another function, not in a
"raw" select statement.

HTH

- Richard Huxton

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2001-02-17 14:18:04 Re: Case insensitive selects?
Previous Message MMM 2001-02-17 09:32:23 Foreign keys