Re: Function returns mutliple rows - HELP - Mailing list pgsql-general

From Stephan Szabo
Subject Re: Function returns mutliple rows - HELP
Date
Msg-id 20030127084913.C78091-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Function returns mutliple rows - HELP  (juleni <juleni@seznam.cz>)
List pgsql-general
On Mon, 27 Jan 2003, juleni wrote:

>   How can I make function returning multiple tuples?
>
>   For example:
>   ============
>   I have a table COMPANY: id_company | company_name |  country
>                            -------------------------------------
>                                 1    |  Company 1   |  Germany
>                                 2    |  Company 2   |  Germany
>                                 3    |  Company 3   |  Slovakia
>                                 4    |  Company 4   |  Slovakia
>                                 5    |  Company 5   |  Slovakia
>                                 6    |  Company 6   |  Italy
>
>   I need a function returning all 'company IDs' and 'company names'
>   from 'Slovakia'.
>   The parameter to the function is 'country'.
>
>   Can anybody give me a simple example how to do it using pl/pgsql by
> function returning more tuples?

The set returning functions document on techdocs might help:
http://techdocs.postgresql.org/guides/SetReturningFunctions

For something that simple, I'd probably say that you could get away with a
simple sql function, though, probably something like:
create function getcompaniesbycountry(text) returns company as
'select * from company where country = $1;' language 'sql';


pgsql-general by date:

Previous
From: will trillich
Date:
Subject: Re: too many users for postgresql? :)
Next
From: will trillich
Date:
Subject: Re: too many users for postgresql? :)