Search Postgresql Archives

Re: NEW in Rule makes another nextval call?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

--
  Richard Huxton
  Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
      choose an index scan if your joining column's datatypes do not
      match

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux