Re: CREATE SCHEMA $1? - Mailing list pgsql-general

From greg@turnstep.com
Subject Re: CREATE SCHEMA $1?
Date
Msg-id 06c2ca015254b4472c5d6915ff1a6148@biglumber.com
Whole thread Raw
In response to CREATE SCHEMA $1?  (wtf <wtf@despammed.com>)
List pgsql-general
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


> I [need to] to create schema with arbitrary name but it seems CREATE SCHEMA
> doesn't accept anythig different from a constant as an argument.

The CREATE SCHEMA command needs to be passed a literal string;
one way around this problem is to use a function:

CREATE OR REPLACE FUNCTION createschema(TEXT) RETURNS VOID AS '
BEGIN
EXECUTE \'CREATE SCHEMA \' || quote_ident($1);
RETURN;
END;
' LANGUAGE plpgsql STABLE RETURNS NULL ON NULL INPUT;


- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200311291203
-----BEGIN PGP SIGNATURE-----

iD8DBQE/yNnbvJuQZxSWSsgRAhu1AJ0eqZdsCJuIyZqzpYnJg1rIwetxbQCgwy0h
BqUz0q5cvztSJ4NkuUGysdg=
=UMR0
-----END PGP SIGNATURE-----



pgsql-general by date:

Previous
From: Jeff Eckermann
Date:
Subject: Re: Can I get rid of the schemas?
Next
From: Tony
Date:
Subject: Re: Triggers, Stored Procedures, PHP. was: Re: PostgreSQL