Search Postgresql Archives

Re: Rule problem: return value of insert

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

 



Stephen Friedrich <stephen.friedrich@xxxxxxxxxxxx> writes:
> In fact I have found some related mails in the archive, but I really do not
> understand why '0' is returned.
> The documentation (34.5. Rules and Command Status) says if I replace an INSERT
> with another INSERT the value returned should be from the new INSERT statement?

Not when you're using a pile of conditional rules like that.  The last
one to fire determines the result, so you'll only see a nonzero count
when inserting into the last subtable.

I think you'd be better off to forget the rule approach and instead
put a trigger on the parent table that stores the values into the
appropriate subtable and then returns NULL.  Unfortunately that won't
fix the rowcount problem either (because suppressed inserts won't be
counted), but it will certainly outperform a large collection of rules.

			regards, tom lane


[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