On 08/10/2016 10:05 AM, Alexander Farber wrote:
> 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);
With RETURN NEXT you have to build the table a row at a time where
RETURN NEXT is in a LOOP. You also need to assign to the OUT
parameters, in this case the fields in your RETURN TABLE. So something
like, inside LOOP:
word := upper(_word);
score := _score;
RETURN NEXT;
If I am following correctly.
>
> Regards
> Alex
--
Adrian Klaver
adrian.klaver@aklaver.com