Search Postgresql Archives

updating a view

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

 



hi,

i would like to allow updates to a view, but pgsql crashes,
presummably from an infinite loop.

i add a rule like so:

   CREATE RULE update_myview AS ON UPDATE TO myview DO INSTEAD SELECT updater(OLD, NEW);

where updater is a plperl function.  the function updater does a few
comparisons off OLD and NEW (to see what has changed) and then, if
necessary, updates one of the tables that makes up myview:

   spi_exec_query("UPDATE mytable SET somefield = somevalue WHERE somecondition");

i can supply the exact code if you wish, but i think the problem lies
more with my approach than the syntax.  what i think is happening is
that the "update mytable set blah blah" statement is executed, but
that causes an update to myview, which causes my rule to run, which
runs updater etc etc.

i'm not sure how to get around this problem though.  how can i do a
UPDATE myview SET foo = bar, and get that to work without using a
rule, that ends up updating a table that updates myview?

thank you for any help!

matt




[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