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

Поиск
Список
Период
Сортировка
От Dan Fitzpatrick
Тема Re: Update view/table rule order of operations or race condition
Дата
Msg-id D35E88A5-1991-49C0-9B1E-B2AF294F01A7@eparklabs.com
обсуждение исходный текст
Ответ на Update view/table rule order of operations or race condition  (Dan Fitzpatrick <dan@eparklabs.com>)
Ответы Re: Update view/table rule order of operations or race condition  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
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?







В списке pgsql-general по дате отправления:

Предыдущее
От: Raymond O'Donnell
Дата:
Сообщение: Re: \copy command: how to define a tab character as the delimiter
Следующее
От: Tom Lane
Дата:
Сообщение: Re: question on 8.4.2 build postgres C functions