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 DD3DACB0-408C-410B-9261-B702705FBD59@eparklabs.com
обсуждение исходный текст
Ответ на Re: Update view/table rule order of operations or race condition  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On Mar 9, 2010, at 11:00 AM, Tom Lane wrote:

> Dan Fitzpatrick <dan@eparklabs.com> 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 disadvantages of rules: they're
> macros, not functions, and as such don't have any real local
> variables.
> You should probably look into whether you can do what you want with a
> trigger instead of a rule.
>
>             regards, tom lane

Can you have a trigger on a view? I thought you can only use rules
with a view.

As another option, can you pass "NEW" (the incoming data record) as a
variable to a function or does each field in NEW have to be explicitly
passed to the function?





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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: \copy command: how to define a tab character as the delimiter
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: \copy command: how to define a tab character as the delimiter