UPDATE with help of RULES

Поиск
Список
Период
Сортировка
От Volker Krey
Тема UPDATE with help of RULES
Дата
Msg-id 3FAF8D4E.5090808@fz-juelich.de
обсуждение исходный текст
Ответы Re: UPDATE with help of RULES  (Bruno Wolff III <bruno@wolff.to>)
Список pgsql-novice
Hello,

I have a table with a number of columns (e.g. one) plus a date column,
which is by default set to current_date.

CREATE TABLE test
(
column_a varchar(10),
last_altered date DEFAULT current_date,
PRIMARY KEY (column_a)
);

Now I want to create a rule that updates the column last_altered of a
particular row to the date when the row has been altered, i.e. updated
last time. Creating a rule wasn't a problem, but whatever I tried ended
in a loop, because the rule reacts with an update on an update and so on...
I also tried to insert a new row with the current_date after deleting
the original one. The DELETE worked okay, but the INSERT afterwards
always failed and so I ended with deleting instead of updating the table
entry. If I do the INSERT first and then the DELETE there is no such
problem, but this of course only works if the UPDATE includes a change
of column_a (PRIMARY KEY).
Is there a simple way of implementing such an automatic update of the
date entry? If it's not possible on the basis of rules, maybe there is
another way of achieving this aim?

Thanks for your help, Volker.

--
Volker Krey
v.krey@fz-juelich.de


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

Предыдущее
От: "Luc ROLLAND"
Дата:
Сообщение: RE : COPY with null
Следующее
От:
Дата:
Сообщение: Re: error while executing a c program with embedded sql