Re: insert rule instead oddity

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: insert rule instead oddity
Дата
Msg-id 20070313130116.GA12748@svana.org
обсуждение исходный текст
Ответ на insert rule instead oddity  (Sim Zacks <sim@compulab.co.il>)
Ответы Re: insert rule instead oddity  (Sim Zacks <sim@compulab.co.il>)
Re: insert rule instead oddity  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On Tue, Mar 13, 2007 at 02:15:01PM +0200, Sim Zacks wrote:
> select version()
> "PostgreSQL 8.0.1 on i686-pc-linux-gnu, compiled by GCC
> i686-pc-linux-gnu-gcc (GCC) 3.3.5  (Gentoo Linux 3.3.5-r1, ssp-3.3.2-3,
> pie-8.7.7.1)"
>
> I am sure that I must have missed something here because I read the
> documentation and searched the forums and it all seems fairly
> straightforward.

Rules don't work the way you think they do. They're sort of macro
expansions. What's ahppening when you insert is the rule splits it into
two statements, one insert and one update, with the where conditions
adjusted. Depending on the order I imagine that it could do both.

I don't think rules can do what you want. What you need in the SQL
MERGE command, but postgresql doesn't support that. A stored procedure
could do it.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Вложения

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

Предыдущее
От: Sim Zacks
Дата:
Сообщение: insert rule instead oddity
Следующее
От: Erik Jones
Дата:
Сообщение: Re: Tracking disk writes? (again) & bgwriter