Search Postgresql Archives

Re: Update view/table rule order of operations or race condition

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

 



I think I found the problem with this. The rule:

CREATE OR REPLACE RULE insert_options AS
 ON INSERT TO options DO INSTEAD
   (INSERT INTO a (a_id, type_id, name)
      VALUES (new.options_id, 6, new.options_name);
    UPDATE a_item SET val = new.quantity
      WHERE a_item.a_id = new.options_id AND a_item.type_id = 1;
    UPDATE a_item SET val = new.price
      WHERE a_item.a_id = new.options_id AND a_item.type_id = 2;
    UPDATE a_item SET val = new.discount
      WHERE a_item.a_id = new.options_id AND a_item.type_id = 3;
);


Is creating a new value from the sequence a_a_id_seq for "new.options_id" on each UPDATE call. How do I use the variable new.options_id in the three update statements without incrementing the sequence again?







--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[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