Confused about a function returning SETOF

Поиск
Список
Период
Сортировка
От Ken Winter
Тема Confused about a function returning SETOF
Дата
Msg-id 008801c64d65$2cde9c60$6706a8c0@kenxp
обсуждение исходный текст
Ответы Re: Confused about a function returning SETOF  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general

I have the following function:

 

CREATE or REPLACE FUNCTION public.lov_personinorganization_role_status(

varchar,

varchar)

RETURNS SETOF person_status_in_organization AS

$BODY$

DECLARE

    rec person_status_in_organization%ROWTYPE;

    role ALIAS FOR $1;

    from_status ALIAS FOR $2;

BEGIN

    FOR rec IN

        SELECT * FROM person_status_in_organization lov,

            status_in_organization_change_lov res

        WHERE res.role = role

            AND res.from_status = from_status

            AND lov.role = res.role

            AND lov.status = res.to_status

        ORDER BY lov.display_order

    LOOP

        RETURN NEXT rec;

    END LOOP; -- FOR rec IN person_status_in_organization

    RETURN;

END; -- of lov_personinorganization_role_status

$BODY$

LANGUAGE 'plpgsql' VOLATILE;

 

Where person_status_in_organization is a table.

 

When I try to invoke it with:

 

select lov_personinorganization_role_status('Student','Applicant');

 

I get the error message:

 

ERROR:  set-valued function called in context that cannot accept a set

CONTEXT:  PL/pgSQL function "lov_personinorganization_role_status" line 15 at return next

 

Where have I gone astray?

 

~ TIA

~ Ken

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: PANIC: heap_update_redo: no block
Следующее
От: Tom Lane
Дата:
Сообщение: Re: How I can get the real data type result instead of