pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: sirius <fhw0044remove@hsw.fhz.ch>
To: pgsql-sql@postgresql.org
Subject: create databases with plpgsql
Date: Tue, 08 Apr 2003 11:54:05 +0200
Message-ID: <3E929C3D.3010704@hsw.fhz.ch> (raw)

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




view thread (2+ messages)  latest in thread

Message-ID: <3E929C3D.3010704@hsw.fhz.ch>
Permalink:  ../3E929C3D.3010704@hsw.fhz.ch/
Also on:    postgresql.org/message-id/3E929C3D.3010704@hsw.fhz.ch

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: fhw0044remove@hsw.fhz.ch
  Subject: Re: create databases with plpgsql
  In-Reply-To: <3E929C3D.3010704@hsw.fhz.ch>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox