Re: Insert Rule

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: Insert Rule
Дата
Msg-id 20060901141508.GQ12644@svana.org
обсуждение исходный текст
Ответ на Insert Rule  (Curtis Scheer <Curtis@DAYCOS.com>)
Список pgsql-general
On Fri, Sep 01, 2006 at 08:22:44AM -0500, Curtis Scheer wrote:
> I'm trying to prevent any further input of a particular field value via an
> insert rule with the following rule.

<snip>

> Basically the stored procedure that it calls raises an exception. The
> behavior I wanted\excepted was to call the stored procedure when foovalue =
> 1 and to execute a regular insert when foovalue <> 1. What its doing is
> calling the stored procedure when foovalue = 1, that part works just fine.
> However, when I try to insert a record into foo with any other value besides
> 1 it actually inserts the record but doesn't return the # of rows affected.
> Is there something else I need to add to the rule so that it returns the
> number of rows affected like normal?

Rules are like macros. What's happening is that each insert query on
that table is being rewritten into two queries, one the original query,
the other your query with the condition. It's the result of the second
query that you're seeing.

It sounds like you really want a trigger, or perhaps just a CHECK
constraint.

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 по дате отправления:

Предыдущее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: [pgsql-advocacy] Training (from Thought provoking...)
Следующее
От: Stefan Kaltenbrunner
Дата:
Сообщение: Re: [pgsql-advocacy] Thought provoking piece on