Dynamic PL/pgSQL

Поиск
Список
Период
Сортировка
Искать

Dynamic PL/pgSQL

От:
"Ruediger Herrmann" <ruediger.herrmann@gmx.de>
Дата:

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

Re: Dynamic PL/pgSQL

От:
PFC <lists@boutiquenumerique.com>
Дата:

> 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.
In your scritp, put a CREATE FUNCTION and then call it and drop it ;)

FAQ