Hvis du vil returnere et resultat, skal du bruge return query
i PL/pgSQL som dokumenteret i manualen
CREATE OR REPLACE FUNCTION dwgcould.returnallcolumns(IN sessionId character varying)
RETURNS SETOF public.mytable AS
$BODY$
BEGIN
return query --<< this was missing
SELECT *
FROM public.mytable
WHERE session_id = returnallcolumns.sessionId
ORDER BY pro_id DESC LIMIT 1;
END;
$BODY$
LANGUAGE plpgsql VOLATILE;
Men du behøver ikke PL/pgSQL til dette, en simpel SQL-funktion vil være mere effektiv:
CREATE OR REPLACE FUNCTION dwgcould.returnallcolumns(IN sessionId character varying)
RETURNS SETOF public.mytable AS
$BODY$
SELECT *
FROM public.mytable
WHERE session_id = returnallcolumns.sessionId
ORDER BY pro_id DESC LIMIT 1;
$BODY$
LANGUAGE sql;