Re: [GENERAL] How to create trigger if it does not exist

2013-02-15 Thread mustachebrownbear
Hi Guys, Using CASCADE can be a bit dangerous as there might be other tables, functions, views etc. that will be dropped but they are not meant to be. Try this: DO $$ BEGIN IF NOT EXISTS(SELECT * FROM information_schema.triggers WHERE event_object_tabl

[GENERAL] How to create trigger if it does not exist

2007-05-28 Thread Andrus
CREATE TRIGGER mycheck_trigger BEFORE INSERT OR UPDATE ON mytbl FOR EACH ROW EXECUTE PROCEDURE mycheck_pkey(); aborts transaction if trigger already exists. There in no CREATE OR REPLACE TRIGGER command in PostgreSQL How to create trigger only when it does not exist ? Andrus. --

Re: [GENERAL] How to create trigger if it does not exist

2007-05-28 Thread Andrus
>> How to create trigger only when it does not exist ? > DROP TRIGGER IF EXISTS... > > See: > > http://www.postgresql.org/docs/8.2/static/sql-droptrigger.html Thank you. This doc says that dropping trigger drops depending objects also. Which objects depend on the user-defined trigger so that the

Re: [GENERAL] How to create trigger if it does not exist

2007-05-28 Thread Andrus
"Rodrigo De León" <[EMAIL PROTECTED]> kirjutas sõnumis news:[EMAIL PROTECTED] > On May 26, 5:58 pm, "Andrus" <[EMAIL PROTECTED]> wrote: >> Thank you. >> This doc says that dropping trigger drops depending objects also. > > Only if you use CASCADE (default is RESTRICT). > If I do not use CASCADE

Re: [GENERAL] How to create trigger if it does not exist

2007-05-27 Thread Rodrigo De León
On May 26, 5:58 pm, "Andrus" <[EMAIL PROTECTED]> wrote: > Thank you. > This doc says that dropping trigger drops depending objects also. Only if you use CASCADE (default is RESTRICT). ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

Re: [GENERAL] How to create trigger if it does not exist

2007-05-26 Thread Rodrigo De León
Andrus ha escrito: > CREATE TRIGGER mycheck_trigger BEFORE INSERT OR UPDATE ON mytbl > FOR EACH ROW EXECUTE PROCEDURE mycheck_pkey(); > > aborts transaction if trigger already exists. > > There in no CREATE OR REPLACE TRIGGER command in PostgreSQL > > How to create trigger only when it does not