Re: How to create trigger if it does not exist

Поиск
Список
Период
Сортировка
От mustachebrownbear
Тема Re: How to create trigger if it does not exist
Дата
Msg-id 1360944248465-5745434.post@n5.nabble.com
обсуждение исходный текст
Ответ на Re: How to create trigger if it does not exist  ("Andrus" <kobruleht2@hot.ee>)
Список 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.

В списке pgsql-general по дате отправления:

Предыдущее
От: "René Romero Benavides"
Дата:
Сообщение: Re: PG9.2.3. Query hanging: SELECT count(*) FROM pg_catalog.pg_class...
Следующее
От: Cochise Ruhulessin
Дата:
Сообщение: Re: Immutable functions, Exceptions and the Query Optimizer