agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
Set flag column on update if other columns change?
3+ messages / 2 participants
[nested] [flat]

* Set flag column on update if other columns change?
@ 2014-05-27 16:00  Steve Wampler <swampler@noao.edu>
  0 siblings, 1 reply; 3+ messages in thread

From: Steve Wampler @ 2014-05-27 16:00 UTC (permalink / raw)
  To: pgsql-sql


I've got a table where updates that actually change things need to
record in the row that the row has been modified.  I'm assuming that a
trigger function (OK to be plpgsql, performance isn't much of
an issue) is the best way to do this, but haven't done much
with trigger functions.  Can someone give me some pointers
on how this might be accomplished?  I have to check for
changes in a subset of the columns (e.g. ignore timestamps, etc.).

Thanks in advance!
Steve
-- 
Steve Wampler -- swampler@noao.edu
The gods that smiled on your birth are now laughing out loud.


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Set flag column on update if other columns change?
@ 2014-05-27 16:21  Andreas Kretschmer <andreas@a-kretschmer.de>
  parent: Steve Wampler <swampler@noao.edu>
  0 siblings, 1 reply; 3+ messages in thread

From: Andreas Kretschmer @ 2014-05-27 16:21 UTC (permalink / raw)
  To: pgsql-sql; Steve Wampler <swampler@noao.edu>



> Steve Wampler <swampler@noao.edu> hat am 27. Mai 2014 um 18:00 geschrieben:
>
>
>
> I've got a table where updates that actually change things need to
> record in the row that the row has been modified.  I'm assuming that a
> trigger function (OK to be plpgsql, performance isn't much of
> an issue) is the best way to do this, but haven't done much
> with trigger functions.  Can someone give me some pointers
> on how this might be accomplished?  I have to check for
> changes in a subset of the columns (e.g. ignore timestamps, etc.).

Trigger BEFORE, compare NEW. with OLD.. Easy.


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Set flag column on update if other columns change?
@ 2014-05-27 16:23  Steve Wampler <swampler@noao.edu>
  parent: Andreas Kretschmer <andreas@a-kretschmer.de>
  0 siblings, 0 replies; 3+ messages in thread

From: Steve Wampler @ 2014-05-27 16:23 UTC (permalink / raw)
  To: Andreas Kretschmer <andreas@a-kretschmer.de>; pgsql-sql

On 05/27/2014 09:21 AM, Andreas Kretschmer wrote:
>> Steve Wampler <swampler@noao.edu> hat am 27. Mai 2014 um 18:00 geschrieben:
>> I've got a table where updates that actually change things need to
>> record in the row that the row has been modified.  I'm assuming that a
>> trigger function (OK to be plpgsql, performance isn't much of
>> an issue) is the best way to do this, but haven't done much
>> with trigger functions.  Can someone give me some pointers
>> on how this might be accomplished?  I have to check for
>> changes in a subset of the columns (e.g. ignore timestamps, etc.).
>
> Trigger BEFORE, compare NEW. with OLD.. Easy.

Thanks!  I didn't know about OLD...


-- 
Steve Wampler -- swampler@noao.edu
The gods that smiled on your birth are now laughing out loud.


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2014-05-27 16:23 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-05-27 16:00 Set flag column on update if other columns change? Steve Wampler <swampler@noao.edu>
2014-05-27 16:21 ` Andreas Kretschmer <andreas@a-kretschmer.de>
2014-05-27 16:23   ` Steve Wampler <swampler@noao.edu>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox