Re: return multiple rows - Mailing list pgsql-general

From Raymond O'Donnell
Subject Re: return multiple rows
Date
Msg-id 4AAA6FBB.2040309@iol.ie
Whole thread Raw
In response to return multiple rows  (Rakotomandimby Mihamina <mihamina@gulfsat.mg>)
List pgsql-general
On 11/09/2009 15:53, Rakotomandimby Mihamina wrote:
>
> It returns only one row, like this:
>     +----+----------+--------------------+----+-------+
>     | id | UserName | Attribute          | op | Value |
>     +----+----------+--------------------+----+-------+
>     | 1  | bartek   | Cleartext-Password | := | 1234  |
>     +----+----------+--------------------+----+-------+
>
> I would like it to return
>     +----+----------+--------------------+----+-------+
>     | id | UserName | Attribute          | op | Value |
>     +----+----------+--------------------+----+-------+
>     | 1  | bartek   | Cleartext-Password | := | 1234  |
>     | 3  | bartek   | Simultaneous-Use   | := | 1     |
>     +----+----------+--------------------+----+-------+

You need to declare the function as returning SETOF radcheck, and then
use the RETURN NEXT construct - see the pl/pgsql docs here:

http://www.postgresql.org/docs/8.4/static/plpgsql-control-structures.html#PLPGSQL-STATEMENTS-RETURNING

There's an example here of how you do this.

> *But*, I would like to _hardcode_ the "Simultaneous-Use" row.
> If I use a FUNCTION to build the "Cleartext-Password" row, it's because
> the data structure
> could not have been feetched simply.

I'm not sure what you're getting at here.

Ray.


------------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod@iol.ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------

pgsql-general by date:

Previous
From: Rakotomandimby Mihamina
Date:
Subject: Re: return multiple rows
Next
From: Merlin Moncure
Date:
Subject: Re: constraint definition on an array column?