Search Postgresql Archives

Re: PostgreSQL: Question about rules

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

 



On Fri, 2006-11-17 at 11:49 -0800, Jeremy Smith wrote:

> Now, the default value for new.id gets evaluated *each time* I
> reference new.id - meaning the rule's first insert sees N for new.id
> while the rule's second insert sees N+1.  That is kind of odd - I
> would think that the default value would get evaluated and then
> assigned to new.id (since it is a concrete row), but that appears not
> to be the case.
> 
> My stopgap solution to this is to call a PSQL/PL function for the body
> of the rule, which can store new.id in a variable so it is evaluated
> only once.  If there is a way to do this inside the rule without
> resorting to creating a view, 3 rules and 3 functions for every child
> table, I would love to hear about it!
> 

I think you're operating on the edge of what rules are supposed to do. A
rule won't copy values or create variables, which is why you needed
COALESCE.

Why do you need so many functions though? Won't one SQL function do the
trick?

Regards,
	Jeff Davis



[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