Re: Coalesce in PostgreSQL trigger does not fire on upddate

Поиск
Список
Период
Сортировка
От Christian Barthel
Тема Re: Coalesce in PostgreSQL trigger does not fire on upddate
Дата
Msg-id 87blq9qzuk.fsf@barthel.ch
обсуждение исходный текст
Ответ на Coalesce in PostgreSQL trigger does not fire on upddate  (ALT SHN <i.geografica@alt-shn.org>)
Ответы Re: Coalesce in PostgreSQL trigger does not fire on upddate  (ALT SHN <i.geografica@alt-shn.org>)
Список pgsql-novice
ALT SHN <i.geografica@alt-shn.org> writes:

[..]
> However this trigger only fires on INSERT, nothing happens if
> an UPDATE is made. How can have this trigger also firing in the
> case of an UPDATE? 

I have just tested it on PostgreSQL 11 (FreeBSD) and it seems to
work (at least, it is what I would expect):


bch=# select id,taxon,reino,phylum,subphylum,classe,especie from
 taxon where id = 3; 
 id | taxon | reino | phylum | subphylum | classe | especie 
----+-------+-------+--------+-----------+--------+---------
(0 rows)

bch=# insert into taxon(reino,classe) values ('1', '2');
INSERT 0 1
bch=# select id,taxon,reino,phylum,subphylum,classe,especie from
taxon where id = 3; 
 id | taxon | reino | phylum | subphylum | classe | especie 
----+-------+-------+--------+-----------+--------+---------
  3 | 2     | 1     |        |           | 2      | 
(1 row)

bch=# update taxon set especie='99' where id = 3;
UPDATE 1
bch=# select id,taxon,reino,phylum,subphylum,classe,especie from
taxon where id = 3; 
 id | taxon | reino | phylum | subphylum | classe | especie 
----+-------+-------+--------+-----------+--------+---------
  3 | 99    | 1     |        |           | 2      | 99
(1 row)

Are there any other triggers preventing the update?  You may also
write some RAISE NOTICE messages into the trigger to see when it
is being executed.

-- 
Christian Barthel <bch@online.de>



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

Предыдущее
От: ALT SHN
Дата:
Сообщение: Coalesce in PostgreSQL trigger does not fire on upddate
Следующее
От: ALT SHN
Дата:
Сообщение: Re: Coalesce in PostgreSQL trigger does not fire on upddate