Re: Rule on tabel

From: DeJuan Jackson <djackson(at)speedfc(dot)com>
To: "Markus(dot)Schmitz" <member29397(at)dbforums(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Rule on tabel
Date: 2003-05-16 19:58:02
Message-ID: 3EC542CA.2000102@speedfc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Look at the docs for triggers and pay special attention to NEW/OLD you
want to change the value in NEW.increase and return it. I'd give you a
more concrete example but I can't get to www.postgresql.org right now
myself.

Don't know if this is doable using a rule, and if it was you might get n
infinite recursion because rules are fired after the insert/update,
which means update happens to the row, rule fires and updates the row,
rule fires and updates the row, rule fires and updates the row, ....

Markus.Schmitz wrote:

>Hi their,
>I want to create a rule, whenever a specific row in a table is
>increased, another row is incremented.
>
>Let's say, I have a table like this:
>CREATE TABLE "test" (
> "Code" VARCHAR(20) NOT NULL,
> "Number" INTEGER NOT NULL,
> "increase" INTEGER NOT NULL,
> PRIMARY KEY("Code")
>)
>
>So, I want to have a rule (or trigger or whatever) which does the
>following job:
>
>Whenever the Number filed is updated and the new value is bigger than
>the old once, the increase field should be incremented (increase++).
>
>Can anybody tell me how to do so ?
>
>Thanks
>
>Markus
>
>--
>Posted via http://dbforums.com
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 5: Have you checked our extensive FAQ?
>
>http://www.postgresql.org/docs/faqs/FAQ.html
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-05-16 20:02:19 Re: priority on a process
Previous Message Tom Lane 2003-05-16 19:56:05 Re: How return a refcusor using functions????