Re: 7.1 PL/pgSQL EXECUTE Command

From: "Dominic J(dot) Eidson" <sauron(at)the-infinite(dot)org>
To: Brian Troxell <trox(at)mindspring(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: 7.1 PL/pgSQL EXECUTE Command
Date: 2001-01-04 00:22:28
Message-ID: Pine.LNX.4.21.0101031816360.18454-100000@morannon.the-infinite.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 3 Jan 2001, Brian Troxell wrote:

> I know that the beta 7.1 release adds the capability to do dynamic
> queries in PL/pgSQL using the new EXECUTE command.

From one of my triggers:

-- Create trigger function to be run upon deletes
CREATE FUNCTION spares_dbs_delete_trig() RETURNS opaque AS '
BEGIN

EXECUTE '' DROP TRIGGER spares_'' || OLD.dbs_name || ''_update_trig ON
'' || OLD.dbs_name || '';'';

EXECUTE '' DROP TABLE '' || OLD.dbs_name || '';'';
EXECUTE '' DROP SEQUENCE '' || OLD.dbs_name || ''_'' || OLD.dbs_name ||
''_id_seq;'';

RETURN OLD;
END;
' LANGUAGE 'plpgsql';

Assuming that OLD.dbs_name == 'site1', will do the following:

DROP TRIGGER spares_site1_update_trig ON site1;
DROP TABLE site1;
DROP SEQUENCE site1_site1_id_seq;

As to what in the world I'm doing... don't ask. It's messy :)

--
Dominic J. Eidson
"Baruk Khazad! Khazad ai-menu!" - Gimli
-------------------------------------------------------------------------------
http://www.the-infinite.org/ http://www.the-infinite.org/~dominic/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John Clark L. Naldoza 2001-01-04 00:52:09 Re: How passwords can be crypted in postgres?
Previous Message Brian Troxell 2001-01-04 00:01:33 7.1 PL/pgSQL EXECUTE Command