Re: FUNCTION returns SETOF

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: FUNCTION returns SETOF
Дата
Msg-id 491.1148392165@sss.pgh.pa.us
обсуждение исходный текст
Ответ на FUNCTION returns SETOF  (Rafal Pietrak <rafal@zorro.isa-geek.com>)
Список pgsql-general
Rafal Pietrak <rafal@zorro.isa-geek.com> writes:
> CREATE FUNCTION new_user (text,text) RETURNS SETOF people AS $$
>     CREATE ROLE $1 PASSWORD $2;
>     SELECT CASE WHEN $2 is not null THEN ROW($1, null, null, null)::people
> ELSE null::ludzie END
> $$ language sql;

> "ERROR:  function returning set of rows cannot return null value"

If you want to return no rows, then return no rows.  Something like

    SELECT ROW($1, null, null, null)::people WHERE $2 is not null;

            regards, tom lane

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

Предыдущее
От: Sim Zacks
Дата:
Сообщение: functions and plans
Следующее
От: Tom Lane
Дата:
Сообщение: Re: functions and plans