I have worked out the following function
CREATE OR REPLACE FUNCTION lgis_overview(id_number int) /*id of object*/
RETURNS TABLE(datatype text, object_number int, object_name text,output text, link text)
AS
$$
BEGIN
RETURN QUERY
(select tags.datatype::text, objects.id::int, objects.name::text, lgis_getvalue(tags.datatype::text, foo.id::int)::text, lgis_objectname(output)
from tags, objects,(select * from values
where object_id = id_number) as foo
where tags.id = foo.tag_id
and objects.id = foo.object_id);
END;
$$
LANGUAGE 'plpgsql' VOLATILE;
This function gives this output:
select * from lgis_overview(148830)
Unfortunatelly, when i use this function in this form, the output is a list of record types:
select lgis_overview(id)
from objects
limit 10
In what (clean) way can I rewrite the function so that the output is a table, or how should I use the function so that the output is a table?
Set returning functions should be used in the
FROM
clause (as you did in your first query).If you need to pass it a column value, use a lateral join: