Re: a trigger question

Поиск
Список
Период
Сортировка
От Zhou, Lixin
Тема Re: a trigger question
Дата
Msg-id 6EDF654BC7BFE648AB2E734727E7078DAEC77B@illumina24.illumina.com
обсуждение исходный текст
Ответ на a trigger question  (pblunat <pblunat@ujf-grenoble.fr>)
Список pgsql-general
Thanks Jan!

>> 1) Fire the trigger AFTER INSERT.  BEFORE INSERT won't work.
>> 2) Deferrable does not seem to be important.

>Jan    1) Fire the trigger BEFORE INSERT does work
>Jan    2) If you make the constraint deferred
>Jan    3) And let the trigger return NEW instead of NULL;

This is a really interesting trick!

>> I've tested above, it does work as expected for PK/FKs that are integers.

>Jan    It also works for all other types of keys.

Yes, it should as I pointed out in another email.

I had troubles because I used quot_literal on a new.varchar value within the
PLPGSQL function.  This should cause SQL syntax error (eg: insert into
tbl(a_string) values (''this is a string to be inserted but it will fail to
insert.'') but I got the error message as "referential integrity error"
instead of SQL syntax error.

Thanks again, Jan!  I learnt a lot.

Lixin Zhou

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

Предыдущее
От: "Lee Green"
Дата:
Сообщение: Re: [ADMIN] performance issue using DBI
Следующее
От: "Zhou, Lixin"
Дата:
Сообщение: Re: a trigger question