Re: Rule on tabel
От | DeJuan Jackson |
---|---|
Тема | Re: Rule on tabel |
Дата | |
Msg-id | 3EC542CA.2000102@speedfc.com обсуждение исходный текст |
Ответ на | Rule on tabel (Markus.Schmitz <member29397@dbforums.com>) |
Список | 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 > >
В списке pgsql-general по дате отправления: