Search Postgresql Archives

Re: new.id has wrong value in INSERT RULE

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

 



"Ian McFarland" <ian@xxxxxxxxxxxxxxxx> writes:
> CREATE RULE table_b_insert_rule  AS ON INSERT TO table_b
> 	DO (UPDATE table_b SET active = 'f', yield = new.id WHERE table_a_id
> = new.table_a_id AND id != new.id;);

Rules are macros.  Since what is substituted for new.id in this case is
a nextval() call, you have a multiple-evaluation problem.  The above is
a pretty horrid way to do things anyway --- you should probably be using
a trigger instead.

			regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

[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