Search Postgresql Archives

Re: How to create trigger if it does not exist

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux