Dynamic PL/pgSQL

From: "Ruediger Herrmann" <ruediger(dot)herrmann(at)gmx(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: Dynamic PL/pgSQL
Date: 2005-06-15 22:10:56
Message-ID: 7884.1118873456@www67.gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


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 ++

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Vsevolod (Simon) Ilyushchenko 2005-06-15 22:45:56 cursor "<unnamed portal 1>" does not exist
Previous Message Thomas Kellerer 2005-06-15 22:08:18 Re: SELECT very slow