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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dan Fitzpatrick <dan(at)eparklabs(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Update view/table rule order of operations or race condition
Date: 2010-03-09 18:00:42
Message-ID: 24216.1268157642@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dan Fitzpatrick <dan(at)eparklabs(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Josh Kupershmidt 2010-03-09 18:02:03 Re: Urgent help needed- alias name in update statement
Previous Message Tom Lane 2010-03-09 17:56:26 Re: question on 8.4.2 build postgres C functions