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

2010-03-09 Thread Dan Fitzpatrick
On Mar 9, 2010, at 11:00 AM, Tom Lane wrote: Dan Fitzpatrick writes: The rule 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? You

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

2010-03-09 Thread Tom Lane
Dan Fitzpatrick writes: > The rule 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? You don't. This is one of the major disad

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

2010-03-09 Thread Dan Fitzpatrick
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

[GENERAL] Update view/table rule order of operations or race condition

2010-03-09 Thread Dan Fitzpatrick
I have a table with a trigger that inserts records into a second table on insert. I have a view that has a rule that inserts a record into the first table then updates the records that the first table's trigger inserted into the second table. From what I can see, when the view rule executes