Re: Shorthand syntax for triggers

Поиск
Список
Период
Сортировка
От Sergey Konoplev
Тема Re: Shorthand syntax for triggers
Дата
Msg-id CAL_0b1tpJbeubKrhp9Nme=fYFJU2PG9q+2c_-FsBsZ7A7m-q4A@mail.gmail.com
обсуждение исходный текст
Ответ на Shorthand syntax for triggers  (Joe Van Dyk <joe@tanga.com>)
Ответы Re: Shorthand syntax for triggers  (Moshe Jacobson <moshe@neadwerx.com>)
Список pgsql-general
On Wed, Oct 10, 2012 at 9:22 AM, Joe Van Dyk <joe@tanga.com> wrote:
> I wish I could do:
>
> create trigger some_trigger after insert on products
> execute procedure do $$ begin
> insert into audits values (CHANGED.value);
> end $$ language plpgsql;

IF TG_OP = 'DELETE' THEN RENAME OLD TO myrow;
ELSE RENAME NEW TO myrow; END IF;

and then use

insert into audits values (myrow.value);

>
>
> Changes/improvements:
>
> 1. Triggers default to 'for each row'
>
> 2. Triggers can use anonymous functions
>
> 3. Triggers can access a special CHANGED value that's either NEW for insert
> or updates, or OLD for deletes.
>
> 4. Default for 'after insert' triggers is to return null, as I believe it
> doesn't matter what you return here.
>
> 5. Way less repetitive typing.
>
>
> Thoughts? Is this a terrible idea?



--
Sergey Konoplev

a database and software architect
http://www.linkedin.com/in/grayhemp

Jabber: gray.ru@gmail.com Skype: gray-hemp Phone: +14158679984


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

Предыдущее
От: Alban Hertroys
Дата:
Сообщение: Re: pymssql Connection to the database failed for an unknown reason
Следующее
От: Gavin Flower
Дата:
Сообщение: Re: Index only scan