I know that some similar questions have been asked before but none of the answers worked for me! I use POSTGRESQL 8.4 and am trying to return an array of BIGINT values from a function. My query looks like:
CREATE OR REPLACE FUNCTION public.bigint_func(
in "in_arg" BIGINT)
RETURNS SETOF BIGINT
AS
$body$
DECLARE bigint_list BIGINT [ ];
BEGIN
SELECT
id
FROM
table1
INTO bigint_list;
RETURN NEXT;
END
$body$
LANGUAGE 'plpgsql'
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER;
and I'd like to use that function as below:
SELECT *
FROM
table1
JOIN (SELECT ids
FROM bigint_func(123))t2 ON table1.id = t2.id
but I get the following error:
ERROR: query has no destination for result data
HINT: If you want to discard the results of a SELECT, use PERFORM instead.
How should I write the code for the function?