From: | "Daniel Verite" <daniel(at)manitou-mail(dot)org> |
---|---|
To: | "Sihem MOUALHI" <Sihem(dot)MOUALHI(at)cefe(dot)cnrs(dot)fr> |
Cc: | pgsql-fr-generale(at)postgresql(dot)org |
Subject: | Re: trigger d'historisation |
Date: | 2011-04-12 14:48:51 |
Message-ID: | c8538870-5a3b-4593-b89c-ae0fa9cf4570@mm |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-fr-generale |
Sihem MOUALHI wrote:
> IF (TG_OP = 'DELETE') THEN
> INSERT INTO history_table (date, attribut2, attribut3,...)
> SELECT now(), OLD.attribut2, OLD.attribut3,..
> FROM matable;
>
> ELSIF (TG_OP = 'UPDATE') THEN
> INSERT INTO history_table (date, attribut2, attribut3,...)
> SELECT now(), OLD.attribut2, OLD.attribut3,..
> FROM matable;
> END IF;
Ce code insère autant de lignes dans history_table qu'il y a de lignes dans
matable et ce à chaque opération, ce qui n'est pas le but recherché.
Pour corriger le problème, il faut enlever les "FROM matable" des deux INSERT
puisqu'il s'agit d'insérer OLD.* complètement indépendamment ce qu'il y a
dans matable.
Cordialement,
--
Daniel
From | Date | Subject | |
---|---|---|---|
Next Message | Guillaume Lelarge | 2011-04-12 14:53:25 | Re: trigger d'historisation |
Previous Message | Sihem MOUALHI | 2011-04-12 14:37:42 | Re: trigger d'historisation |