I want to parametrize the name of a view using postgresql. In particular, I want to create a view inside a function and use the parameter for the name of the view.
CREATE OR REPLACE FUNCTION function_to_be(certain_date date) RETURNS void as $$
BEGIN
CREATE OR REPLACE VIEW name_of_schema.test_view AS
SELECT * from test_table;
END;
$$ LANGUAGE plpgsql;
So the desired name of the view should be name_of_schema.test_view_2019_07_29 after executing the function with the parameter .
However, the name should be schema-qualified - such that I could not directly pass a whole string for the name.
Many thanks in advance!