From: | Alexander Farber <alexander(dot)farber(at)gmail(dot)com> |
---|---|
To: | |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: RETURNS TABLE function: ERROR: column reference "word" is ambiguous |
Date: | 2016-08-10 20:14:44 |
Message-ID: | CAADeyWh9wj43H6WsAR8rhBPAmCPwJxi7zVEKnOKz2Z8v41fg8Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
No, actually both variants work for me right now at 9.5.3 on Mac -
On Wed, Aug 10, 2016 at 8:31 PM, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
wrote:
>
>> Given what you are doing, RETURN TABLE it will not work there for the
> same reason it does not work in 9.5:
>
> https://www.postgresql.org/docs/9.6/static/plpgsql-control-
> structures.html#PLPGSQL-STATEMENTS-RETURNING
>
> "If you declared the function with output parameters, write just RETURN
> NEXT with no expression. On each execution, the current values of the
> output parameter variable(s) will be saved for eventual return as a row of
> the result. Note that you must declare the function as returning SETOF
> record when there are multiple output parameters, or SETOF sometype when
> there is just one output parameter of type sometype, in order to create a
> set-returning function with output parameters."
>
Either:
CREATE OR REPLACE FUNCTION words_check_words(
IN in_uid integer,
IN in_gid integer,
IN in_tiles jsonb
OUT out_word varchar,
OUT out_score integer
) RETURNS SETOF RECORD AS
$func$
Or:
CREATE OR REPLACE FUNCTION words_check_words(
IN in_uid integer,
IN in_gid integer,
IN in_tiles jsonb
) RETURNS TABLE (out_word varchar, out_score integer) AS
$func$
And then I assign values to the variables and call RETURN NEXT:
out_word := ... ;
out_score := ... ;
RETURN NEXT;
Regards
Alex
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2016-08-10 20:26:09 | Re: RETURNS TABLE function: ERROR: column reference "word" is ambiguous |
Previous Message | Adrian Klaver | 2016-08-10 18:31:15 | Re: RETURNS TABLE function: ERROR: column reference "word" is ambiguous |