From: | Volker Krey <v(dot)krey(at)fz-juelich(dot)de> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | UPDATE with help of RULES |
Date: | 2003-11-10 13:06:22 |
Message-ID: | 3FAF8D4E.5090808@fz-juelich.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(dot)krey(at)fz-juelich(dot)de
From | Date | Subject | |
---|---|---|---|
Next Message | radha.manohar | 2003-11-10 15:00:27 | Re: error while executing a c program with embedded sql |
Previous Message | Luc ROLLAND | 2003-11-10 12:24:32 | RE : COPY with null |