I am creating a bunch of schemas in a loop. I have something like this:
FOR i in 0 .. num_schemas LOOP
schema_name := 'test' || i;
CREATE SCHEMA testschema;
CREATE TABLE testschema.testtable (
test_id UUID PRIMARY KEY,
test_address VARCHAR
);
END LOOP;
But, this is not working; it tries to create a schema with the literal name 'testschema', instead of test0, test1... test'n'. So, how can I use a variable in this sort of query?