Re: create databases with plpgsql

From: Olleg Samojlov <olleg(at)telecom(dot)mipt(dot)ru>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: create databases with plpgsql
Date: 2003-04-10 09:14:55
Message-ID: b73cmd$2bpo$2@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

As I can now create database is none transactional statment. But
function performed only in transaction. So not. Bu I can mistake.

sirius wrote:
> a novice has the following challenge (problem):
>
> I would like to create a certain number of new databases named stud01,
> stud02...to stud25 with a plpgsql-script. But I have difficulties to
> create a new database with a script. I saw a lot of different scripts in
> the manuals to create tables, but no new db.
>
> Generally, is it possible at all? Do you may have any suggestions,
> workarounds, ideas?
>
> any help will be appreciated...
>
> I tried the these simple script without any loop, unfortunately without
> success:
>
> create or replace function createDB(text) returns text as '
> DECLARE
> DBname ALIAS FOR $1;
> sqlquery text;
> result text;
> BEGIN
> sqlquery := ''CREATE DATABASE %'', DBname;
> EXECUTE( sqlquery );
> RETURN DBname
> END;
> ' language 'plpgsql';
>
> Thank you for your help
>
> sirius
>

--
Olleg Samojlov

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message joostje 2003-04-10 11:21:44 estimates for nested loop very wrong?
Previous Message Olleg Samojlov 2003-04-10 09:12:27 Re: auto-commit