Re: NEW in Rule makes another nextval call?

Поиск
Список
Период
Сортировка
От Sven Willenberger
Тема Re: NEW in Rule makes another nextval call?
Дата
Msg-id 1129818760.21857.18.camel@lanshark.dmv.com
обсуждение исходный текст
Ответ на Re: NEW in Rule makes another nextval call?  (Richard Huxton <dev@archonet.com>)
Ответы Re: NEW in Rule makes another nextval call?  (Richard Huxton <dev@archonet.com>)
Список pgsql-general
On Thu, 2005-10-20 at 15:01 +0100, Richard Huxton wrote:
> Sven Willenberger wrote:
> >  Is this intended behavior? or is the NEW
> > acting as a macro that is replace by "nextval(<sequence name>)" ?
>
> Well, it's understood behaviour even if not quite "intended".
>
> You are quite right, rules basically act like macros with all the
> limitations they have. What is actually happening behind the scenes is
> that the query is being rewritten to alter the query-plan tree. You
> should be able to get your rule to work by referring to
> currval(<sequence-name>) rather than NEW.custid.
>
> However, in this particular case I think you want an after insert
> trigger on customer rather than a rule.
>

As as AFTER INSERT trigger, I can safely assume here that NEW.custid wil
now properly use the actual value of the custid rather than nextval()? I
have dropped the rule and created the AFTER INSERT trigger so I guess I
will find out shortly enough :-)

Thanks,

Sven


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

Предыдущее
От: Rick Morris
Дата:
Сообщение: Re: 'a' == 'a ' (Was: RE: [pgsql-advocacy] Oracle buysInnobase)
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: NEW in Rule makes another nextval call?