X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 32753476332 for ; Thu, 10 Apr 2003 05:14:59 -0400 (EDT) Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id 35F69475CA9 for ; Thu, 10 Apr 2003 05:14:58 -0400 (EDT) Received: by news.hub.org (Postfix, from userid 8) id E156A43A923; Thu, 10 Apr 2003 05:14:56 -0400 (EDT) From: Olleg Samojlov X-Newsgroups: comp.databases.postgresql.sql Subject: Re: create databases with plpgsql Date: Thu, 10 Apr 2003 13:14:55 +0400 Organization: MIPT Telecom Lines: 39 Message-ID: References: <3E929C3D.3010704@hsw.fhz.ch> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: ru, en In-Reply-To: <3E929C3D.3010704@hsw.fhz.ch> To: pgsql-sql@postgresql.org X-Spam-Status: No, hits=-38.0 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MOZILLA_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/154 X-Sequence-Number: 12855 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