Re: Create Schema functionality question - Mailing list pgsql-general

From Tom Lane
Subject Re: Create Schema functionality question
Date
Msg-id 18533.1077602293@sss.pgh.pa.us
Whole thread Raw
In response to Create Schema functionality question  (Seamus Thomas Carroll <carrolls@cpsc.ucalgary.ca>)
Responses Re: Create Schema functionality question  (Seamus Thomas Carroll <carrolls@cpsc.ucalgary.ca>)
List pgsql-general
Seamus Thomas Carroll <carrolls@cpsc.ucalgary.ca> writes:
> Is there any possible way to create a schema without having
> to hard code the name?

Not in CREATE SCHEMA itself.  But you could use a plpgsql or pltcl
function to construct the needed command as a string, and execute
that.  In plpgsql it'd look something like

    DECLARE newschema text;
    ...
    SELECT INTO newschema agent_schema FROM ... WHERE ...;
    EXECUTE "CREATE SCHEMA " || quote_ident(newschema);
    ...

The same goes for other utility commands (which is to say everything
except SELECT/INSERT/UPDATE/DELETE).

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Found this in the server log on MAC OSX
Next
From: Seamus Thomas Carroll
Date:
Subject: Re: Create Schema functionality question