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@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to