X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 246375280A for ; Wed, 15 Jun 2005 19:10:58 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 11266-04 for ; Wed, 15 Jun 2005 22:10:56 +0000 (GMT) Received: from mail.gmx.net (pop.gmx.de [213.165.64.20]) by svr1.postgresql.org (Postfix) with SMTP id A74A852863 for ; Wed, 15 Jun 2005 19:10:54 -0300 (ADT) Received: (qmail 17002 invoked by uid 0); 15 Jun 2005 22:10:56 -0000 Received: from 84.163.211.201 by www67.gmx.net with HTTP; Thu, 16 Jun 2005 00:10:56 +0200 (MEST) Date: Thu, 16 Jun 2005 00:10:56 +0200 (MEST) From: "Ruediger Herrmann" To: pgsql-sql@postgresql.org MIME-Version: 1.0 Subject: Dynamic PL/pgSQL X-Priority: 3 (Normal) X-Authenticated: #1351255 Message-ID: <7884.1118873456@www67.gmx.net> X-Mailer: WWW-Mail 1.6 (Global Message Exchange) X-Flags: 0001 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.038 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200506/229 X-Sequence-Number: 21830 I plan to run an SQL script - using JDBC - to initialize a database. Right now I have the need to execute serveral statements only under certain conditions. for example: IF NOT EXISTS ( SELECT 1 FROM pg_catalog.pg_user WHERE ussername = 'Jon' ) THEN CREATE USER 'Jon'; END IF; Within a PL/pgSQL function this would be easy, but I need to store the complete initialization script in a text file and execute it as a whole. Is there any way to solve this? Any suggestions are welcome TIA Rüdiger -- Geschenkt: 3 Monate GMX ProMail gratis + 3 Ausgaben stern gratis ++ Jetzt anmelden & testen ++ http://www.gmx.net/de/go/promail ++