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

Re: [GENERAL] update view

1999-11-29 Thread jose soares
You must create a rule to make a view updatable as in the following example:   drop table emp; create table emp (     empno    int,     ename   char(20),     job  char(12),     hiredate date,     sal  money,     comm int,     deptno   int,     level