Re: Create Schema functionality question

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Seamus Thomas Carroll <carrolls(at)cpsc(dot)ucalgary(dot)ca>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Create Schema functionality question
Date: 2004-02-24 05:58:13
Message-ID: 18533.1077602293@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Seamus Thomas Carroll <carrolls(at)cpsc(dot)ucalgary(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joe Conway 2004-02-24 06:11:19 Re: dblink - custom datatypes NOW work :)
Previous Message Tom Lane 2004-02-24 05:50:31 Re: Found this in the server log on MAC OSX