Re: Triggers

Поиск
Список
Период
Сортировка
От Darren Ferguson
Тема Re: Triggers
Дата
Msg-id Pine.LNX.4.44.0208161031390.20926-100000@thread.crystalballinc.com
обсуждение исходный текст
Ответ на Triggers  (Jean-Christian Imbeault <jc@mega-bucks.co.jp>)
Список pgsql-general
You can make the trigger fire before you do the insert and make sure you
get the value and then insert into the table.

Seems really odd that you would do it this way. I can't think why you
would not get the value first and then insert inot the table. I am
assuming you get the value via (a).

Anyway the first paragraph should give you the answer

HTH

On Fri, 16 Aug 2002, Jean-Christian Imbeault wrote:

> I have a with a a column defined as not null. The value however can be
> found by looking it up in another table. I would like to create a
> trigger that after insert would look up the need value and put it in the
> record being inserted.
>
> Unfortunately the column is defined as not null so I fear the insert
> would fail and the trigger never get called. How can I get around this?
>
> i.e.
>
> create table t {
>
> id  serial  primary key,
> a   integer not null,
> b   integer not null  -- b can be found in another table
> };
>
> insert into t(a) values('1'); -- this would start the trigger and turn
> the insert into:
>
> insert into t(a,b) values('1', 'some value from another table');
>
> Are thriggers the wrong way to go about this?
>
> Jc
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>

--
Darren Ferguson


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

Предыдущее
От: Jean-Christian Imbeault
Дата:
Сообщение: Re: Triggers
Следующее
От: Jean-Christian Imbeault
Дата:
Сообщение: Re: Triggers