Re: Create Schema functionality question

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

From what I have just read EXECUTE requires a prepared statement but
prepared statements only work with SELECT, INSERT, UPDATE, or DELETE.

Does your suggestion take this into account? If so can you explain
further? Is your suggestions meant for "psql"?

Seamus

On Tue, 24 Feb 2004, Tom Lane wrote:

> 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 Tom Lane 2004-02-24 06:27:02 Re: [GENERAL] dblink: rollback transaction
Previous Message Joe Conway 2004-02-24 06:19:13 Re: [GENERAL] dblink: rollback transaction