From: | mustachebrownbear <mustachebrownbear(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: How to create trigger if it does not exist |
Date: | 2013-02-15 16:04:08 |
Message-ID: | 1360944248465-5745434.post@n5.nabble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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_table = 'tablename'
AND trigger_name = 'triggername'
)
THEN
<Insert your create trigger syntx here>;
END IF ;
END;
$$
--
View this message in context: http://postgresql.1045698.n5.nabble.com/How-to-create-trigger-if-it-does-not-exist-tp1882226p5745434.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.
From | Date | Subject | |
---|---|---|---|
Next Message | Gauthier, Dave | 2013-02-15 16:10:42 | Re: How to get stored procedure args list from metadata tables ? |
Previous Message | Glenn Pierce | 2013-02-15 15:51:39 | Case insensitive hstore. |