Re: Functions that return both Output Parameters and recordsets

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Functions that return both Output Parameters and recordsets
Дата
Msg-id 8674.1181570398@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Functions that return both Output Parameters and recordsets  (Jeremy Nix <Jeremy.Nix@sfsltd.com>)
Список pgsql-general
Jeremy Nix <Jeremy.Nix@sfsltd.com> writes:
> I see what you're doing, but I'm not quite sure how to adapt it to what
> I'm doing.  Here's simplified snippet of my code.  Can elaborate on how
> I can return a recordset and the output parameters.?

I suppose what you need is something like

CREATE OR REPLACE FUNCTION Search (OUT TotalRecords int, OUT TotalPages int)
RETURNS SETOF record AS
$BODY$
     FOR myRecord IN
        SELECT cols FROM searchResults
    LOOP
        TotalRecords := myRecord.TotalRecords;
        TotalPages := myRecord.TotalPages;
        RETURN NEXT;
    END LOOP;

Anyway the point is that when you are using OUT parameters you do not
say anything in RETURN or RETURN NEXT.  Whatever you last assigned to
the parameter variables is what's returned.

            regards, tom lane

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: track ddl changes on single database
Следующее
От: "Pit M."
Дата:
Сообщение: Re: transaction problem using cursors