Re: RETURNS TABLE function: ERROR: column reference "word" is ambiguous

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: RETURNS TABLE function: ERROR: column reference "word" is ambiguous
Дата
Msg-id CAFj8pRAUSgkxqius7zaMCNcJHJ=0QXUjGN_MQZ+VgwRyEjNf2w@mail.gmail.com
обсуждение исходный текст
Ответ на Re: RETURNS TABLE function: ERROR: column reference "word" is ambiguous  (Alexander Farber <alexander.farber@gmail.com>)
Ответы Re: RETURNS TABLE function: ERROR: column reference "word" is ambiguous  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: RETURNS TABLE function: ERROR: column reference "word" is ambiguous  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-general


2016-08-10 19:05 GMT+02:00 Alexander Farber <alexander.farber@gmail.com>:
Thank you Adrian and others -

I am trying to replace INSERT into temp table in my custom function by RETURN NEXT, but get an error:

CREATE OR REPLACE FUNCTION words_check_words(
        IN in_uid integer,
        IN in_gid integer,
        IN in_tiles jsonb)
        RETURNS TABLE(word varchar, score integer) AS
$func$
.......
                        -- INSERT INTO _words(word, score)
                        -- VALUES (upper(_word), _score);

                        RETURN NEXT (word, score);


ERROR:  RETURN NEXT cannot have a parameter in function with OUT parameters
LINE 98:                         RETURN NEXT (word, score);

This was limit in older version

you have to assign values to these variables and call RETURN NEXT without any parameters

CREATE OR REPLACE FUNCTION public.foob(OUT a integer, OUT b integer)
 RETURNS SETOF record
 LANGUAGE plpgsql
AS $function$
BEGIN
  a := 10; b := 20;
  RETURN NEXT;
  b := 30;
  RETURN NEXT;
END;
$function$

result
┌────┬────┐
│ a  │ b  │
╞════╪════╡
│ 10 │ 20 │
│ 10 │ 30 │
└────┴────┘
(2 rows)


 

Regards
Alex

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

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: RETURNS TABLE function: ERROR: column reference "word" is ambiguous
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: RETURNS TABLE function: ERROR: column reference "word" is ambiguous