This is the question:
I want to call a table that i have made inside the WITH from a function.
This is the main query
WITH RECURSIVE session_data AS (
SELECT * FROM (VALUES(1)) t(ntimes)
) SELECT * FROM my_wonderful_function()
This is the function
CREATE FUNCTION my_wonderful_function()
RETURN TABLE (xtimes int)
AS
$$
DECLARE
BEGIN
RETURN SELECT * FROM session_data;
END;
$$ LANGUAGE plgsql
I know, this is probably a strange question but i want to do it, anyone knows how to solve this?