Re: CREATE SCHEMA $1?

From: greg(at)turnstep(dot)com
To: pgsql-general(at)postgresql(dot)org
Cc: wtf(at)despammed(dot)com
Subject: Re: CREATE SCHEMA $1?
Date: 2003-11-29 17:40:52
Message-ID: 06c2ca015254b4472c5d6915ff1a6148@biglumber.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)turnstep(dot)com
PGP Key: 0x14964AC8 200311291203
-----BEGIN PGP SIGNATURE-----

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tony 2003-11-29 17:46:00 Re: Triggers, Stored Procedures, PHP. was: Re: PostgreSQL
Previous Message Jeff Eckermann 2003-11-29 17:30:59 Re: Can I get rid of the schemas?