Re: plpgsql select into

Поиск
Список
Период
Сортировка
От Laurenz Albe
Тема Re: plpgsql select into
Дата
Msg-id 6af818d092cf9afb1f7228bca0cbab03ae17bf4d.camel@cybertec.at
обсуждение исходный текст
Ответ на plpgsql select into  (Roger Mason <rmason@mun.ca>)
Ответы Re: plpgsql select into  (Roger Mason <rmason@mun.ca>)
Список pgsql-novice
On Fri, 2021-08-20 at 08:08 -0230, Roger Mason wrote:
> CREATE OR REPLACE FUNCTION get_info (id text)
>   RETURNS TABLE (
>     tabular_info text
>   )
>   AS $function$
> BEGIN
>   RETURN query WITH a AS (
>     SELECT
>       regexp_split_to_table(info_out, '\n') AS info
>     FROM
>       public.results
>     WHERE
>       public.results.jid = id
> )
>   SELECT
>     * INTO tabular_info
>   FROM
>     a RETURN;
> END;
> $function$
> LANGUAGE plpgsql;
> 
> I execute the function:
> 
> select get_info('1043_1');
> 
> ERROR:  cannot open SELECT query as cursor
> CONTEXT:  PL/pgSQL function get_info(text) line 3 at RETURN QUERY

Omit "INTO tabular_info" from the query.
RETURN QUERY already is a destination for the query result.

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com




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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: plpgsql select into
Следующее
От: Roger Mason
Дата:
Сообщение: Re: plpgsql select into