Skip site navigation (1) Skip section navigation (2)

Re: logging table changes

From: Matthias Leopold <matthias(at)aic(dot)at>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: logging table changes
Date: 2010-09-09 20:54:29
Message-ID: 4C894985.7000006@aic.at (view raw or flat)
Thread:
Lists: pgsql-novice
Am 2010-09-09 20:31, schrieb Rob Richardson:
> So far in this thread, I haven't seen anybody answer what I consider to
> be a very important question about the original poster's requirements:
>
> Why are you updating the history table????
>
> If you update the history table, you lose old history.  Instead, I think
> you should be adding a new record to the history table for every
> alteration made to the old one.  The history table would have to contain
> a field for the type of change that was made (insert, update or delete).
>
> RobR
>

thx for all the answers so far

I wasn't thinking about updating the history table.

"adding a field in the audit table which contains the names of all the 
fields which changed" meant adding this field to the history table 
originally, so it gets filled along with all the others when every 
change to a row is recorded. HOW to "easily" get the values to put there 
i don't know, i don't even know if this approach is sensible at all.

the solutions in the other posts require me to know the field to audit 
in advance. i'm searching for a "easy" solution where "everything" is 
logged and i can make simple queries to the history table for changes in 
ANY field.

i must admit i'm not too familiar with triggers and even functions, so 
maybe i'm heading in the wrong direction or i'm simply asking too much. 
i just thought that i can't be the only one who was looking for this 
kind of functionality (which of course doesn't mean that there is an 
"easy" solution)

i hope i could make myself clear

matthias





In response to

pgsql-novice by date

Next:From: Rodrigo QuezadaDate: 2010-09-09 22:13:12
Subject: Getting The Last Entry
Previous:From: Richard BroersmaDate: 2010-09-09 18:37:44
Subject: Re: logging table changes

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group