Answer the question
In order to leave comments, you need to log in
How to create a table function in PostgreSQL?
Wrote a function:
CREATE OR REPLACE FUNCTION public.get_full_info_about_passenger(INTEGER)
RETURNS SETOF RECORD
AS
$BODY$
BEGIN
SELECT id FROM public.passengers;
END;
$BODY$
LANGUAGE plpgsql VOLATILE;
SELECT id FROM public.get_full_info_about_passenger(2);
a column definition list is required for functions returning "record"
SELECT id FROM public.get_full_info_about_passenger(2) f(id INTEGER);
ERROR: query has no destination for result data
Hint: If you want to discard the results of a SELECT, use PERFORM instead.
Where: PL/pgSQL function "get_full_info_about_passenger" line 8 at SQL statement
Answer the question
In order to leave comments, you need to log in
What perverts. Never use execute if you can do without it.
https://www.postgresql.org/docs/9.4/static/plpgsql...
You can describe in the store what exactly it returns:
CREATE OR REPLACE FUNCTION public.get_full_info_about_passenger(INTEGER)
RETURNS TABLE(
id bigint
)
AS
$BODY$
BEGIN
RETURN QUERY SELECT p.id FROM public.passengers p;
END;
$BODY$
LANGUAGE plpgsql VOLATILE;
CREATE OR REPLACE FUNCTION public.get_full_info_about_passenger(INTEGER)
RETURNS setof bigint
AS
$BODY$
BEGIN
RETURN QUERY SELECT id FROM public.passengers;
END;
$BODY$
LANGUAGE plpgsql VOLATILE;
CREATE OR REPLACE FUNCTION public.get_full_info_about_passenger(INTEGER)
RETURNS setof public.passengers
AS
$BODY$
BEGIN
RETURN QUERY SELECT * FROM public.passengers;
END;
$BODY$
LANGUAGE plpgsql VOLATILE;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question