Re: return multiple rows

Поиск
Список
Период
Сортировка
От Raymond O'Donnell
Тема Re: return multiple rows
Дата
Msg-id 4AAA6FBB.2040309@iol.ie
обсуждение исходный текст
Ответ на return multiple rows  (Rakotomandimby Mihamina <mihamina@gulfsat.mg>)
Список 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 по дате отправления:

Предыдущее
От: Rakotomandimby Mihamina
Дата:
Сообщение: Re: return multiple rows
Следующее
От: Merlin Moncure
Дата:
Сообщение: Re: constraint definition on an array column?