Re: Stored Procedure

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Stored Procedure
Дата
Msg-id 20051122185941.GA18102@winnie.fuhr.org
обсуждение исходный текст
Ответ на Stored Procedure  (Yves Vindevogel <yves.vindevogel@implements.be>)
Ответы Re: Stored Procedure  (Yves Vindevogel <yves.vindevogel@implements.be>)
Список pgsql-performance
On Tue, Nov 22, 2005 at 07:29:37PM +0100, Yves Vindevogel wrote:
> Is there another way in PG to return a recordset from a function than
> to declare a type first ?

In 8.1 some languages support OUT and INOUT parameters.

CREATE FUNCTION foo(IN x integer, INOUT y integer, OUT z integer) AS $$
BEGIN
    y := y * 10;
    z := x * 10;
END;
$$ LANGUAGE plpgsql IMMUTABLE STRICT;

SELECT * FROM foo(1, 2);
 y  | z
----+----
 20 | 10
(1 row)

CREATE FUNCTION fooset(IN x integer, INOUT y integer, OUT z integer)
RETURNS SETOF record AS $$
BEGIN
    y := y * 10;
    z := x * 10;
    RETURN NEXT;
    y := y + 1;
    z := z + 1;
    RETURN NEXT;
END;
$$ LANGUAGE plpgsql IMMUTABLE STRICT;

SELECT * FROM fooset(1, 2);
 y  | z
----+----
 20 | 10
 21 | 11
(2 rows)

--
Michael Fuhr

В списке pgsql-performance по дате отправления:

Предыдущее
От: "Jim Buttafuoco"
Дата:
Сообщение: Re: Stored Procedure
Следующее
От: "Anjan Dave"
Дата:
Сообщение: Re: High context switches occurring