Re: a trigger question

Поиск
Список
Период
Сортировка
От Oliver Elphick
Тема Re: a trigger question
Дата
Msg-id 1023292771.23631.8.camel@linda
обсуждение исходный текст
Ответ на a trigger question  ("Zhou, Lixin" <LZhou@illumina.com>)
Список pgsql-general
On Tue, 2002-06-04 at 21:21, Zhou, Lixin wrote:

> I like to create a trigger on table A.  When a new row is inserted into A
> (ex: with i = 5), I like to have the trigger inserts a new row in table B
> whose field "i" has the same value as that of the A's (ex: i = 5).
>
> As I do this, the error message is something like: "referential integration
> violation - key referenced in B not found in A".  This makes sense to me
> since at the time the trigger inserts in B, A's new row is not visible yet
> -- not committed yet.
>
> How can I solve this problem using trigger?

Declare the foreign key constraints deferrable and defer them in the
session; they will be checked only at the end of the transaction.

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C

     "Let your conversation be without covetousness; and be
      content with such things as ye have. For he hath said,
      I will never leave thee, nor forsake thee."
                                             Hebrews 13:5

Вложения

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

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: a trigger question
Следующее
От: "Peter A. Daly"
Дата:
Сообщение: Re: Insight into indexes? (or inverting then externally)