pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedcreate databases with plpgsql
2+ messages / 2 participants
[nested] [flat]
* create databases with plpgsql
@ 2003-04-08 09:54 sirius <fhw0044remove@hsw.fhz.ch>
2003-04-10 09:14 ` Re: create databases with plpgsql Olleg Samojlov <olleg@telecom.mipt.ru>
0 siblings, 1 reply; 2+ messages in thread
From: sirius @ 2003-04-08 09:54 UTC (permalink / raw)
To: pgsql-sql
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
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: create databases with plpgsql
2003-04-08 09:54 create databases with plpgsql sirius <fhw0044remove@hsw.fhz.ch>
@ 2003-04-10 09:14 ` Olleg Samojlov <olleg@telecom.mipt.ru>
0 siblings, 0 replies; 2+ messages in thread
From: Olleg Samojlov @ 2003-04-10 09:14 UTC (permalink / raw)
To: 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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2003-04-10 09:14 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-04-08 09:54 create databases with plpgsql sirius <fhw0044remove@hsw.fhz.ch>
2003-04-10 09:14 ` Olleg Samojlov <olleg@telecom.mipt.ru>
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