X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5FDFC4758E6 for ; Tue, 8 Apr 2003 06:17:50 -0400 (EDT) Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id 56DE9474E42 for ; Tue, 8 Apr 2003 06:17:49 -0400 (EDT) Received: by news.hub.org (Postfix, from userid 8) id 3858343A89E; Tue, 8 Apr 2003 06:17:49 -0400 (EDT) Message-ID: <3E929C3D.3010704@hsw.fhz.ch> Date: Tue, 08 Apr 2003 11:54:05 +0200 From: sirius User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 X-Accept-Language: en-us, en MIME-Version: 1.0 X-Newsgroups: comp.databases.postgresql.sql Subject: create databases with plpgsql Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Original-NNTP-Posting-Host: 195.186.180.66 Organization: Bluewin AG Lines: 31 Complaints-To: abuse@bluewin.ch X-Original-NNTP-Posting-Host: 127.0.0.1 To: pgsql-sql@postgresql.org X-Spam-Status: No, hits=-12.9 required=5.0 tests=BAYES_01,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/121 X-Sequence-Number: 12822 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