Re: Plpgsql function syntax error at first coalesce statement

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Plpgsql function syntax error at first coalesce statement
Дата
Msg-id 20959.1272238503@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Plpgsql function syntax error at first coalesce statement  (Jeff Ross <jross@wykids.org>)
Список pgsql-general
Jeff Ross <jross@wykids.org> writes:
> On 04/25/10 14:20, Tom Lane wrote:
>> Uh, you're using that as the destination for the FOR loop's SELECT.
>> What exactly is the purpose of having a second SELECT within the loop?

> How else do I get the results I want--name, address, city, state, and so
> on through the list out to whatever calls this function?

Well, you could do

    SELECT all-that-stuff INTO some-record-variable FROM ...;
    RETURN NEXT some-record-variable;

which is more or less what the error message is suggesting.

Or you could merge the computations you want into the first SELECT
(the one in the FOR) and just RETURN NEXT directly from the FOR's
loop variable, instead of having two record variables.

Or you could eliminate the explicit loop altogether and just RETURN
QUERY one-big-query (if you're using a PG version new enough to have
RETURN QUERY).

            regards, tom lane

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

Предыдущее
От: Jeff Ross
Дата:
Сообщение: Re: Plpgsql function syntax error at first coalesce statement
Следующее
От: Megha
Дата:
Сообщение: Help with pgpool-dbt2 database