pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Dynamic PL/pgSQL
2+ messages / 2 participants
[nested] [flat]

* Dynamic PL/pgSQL
@ 2005-06-15 22:10 Ruediger Herrmann <ruediger.herrmann@gmx.de>
  2005-06-19 10:36 ` Re: Dynamic PL/pgSQL PFC <lists@boutiquenumerique.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Ruediger Herrmann @ 2005-06-15 22:10 UTC (permalink / raw)
  To: 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 ++



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Dynamic PL/pgSQL
  2005-06-15 22:10 Dynamic PL/pgSQL Ruediger Herrmann <ruediger.herrmann@gmx.de>
@ 2005-06-19 10:36 ` PFC <lists@boutiquenumerique.com>
  0 siblings, 0 replies; 2+ messages in thread

From: PFC @ 2005-06-19 10:36 UTC (permalink / raw)
  To: Ruediger Herrmann <ruediger.herrmann@gmx.de>; pgsql-sql


> 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 ;)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2005-06-19 10:36 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-06-15 22:10 Dynamic PL/pgSQL Ruediger Herrmann <ruediger.herrmann@gmx.de>
2005-06-19 10:36 ` PFC <lists@boutiquenumerique.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox