pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
NEW and OLD as ROWS
2+ messages / 2 participants
[nested] [flat]

* NEW and OLD as ROWS
@ 2005-08-03 17:52  Craig Servin <cservin@cromagnon.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Craig Servin @ 2005-08-03 17:52 UTC (permalink / raw)
  To: pgsql-sql

I am writing an update trigger that I want to fire when any field changes.  It 
looks like two ROWS can be compared very easily, but not the two RECORDS OLD 
and NEW.

Is there a way to do:

NEW IS DISTINCT FROM OLD

in a trigger?

This would help me not have to write a specific trigger for each table.

Thanks,

Craig



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

* Re: NEW and OLD as ROWS
@ 2005-08-04 13:38  Michael Fuhr <mike@fuhr.org>
  parent: Craig Servin <cservin@cromagnon.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Michael Fuhr @ 2005-08-04 13:38 UTC (permalink / raw)
  To: Craig Servin <cservin@cromagnon.com>; +Cc: pgsql-sql

On Wed, Aug 03, 2005 at 12:52:24PM -0500, Craig Servin wrote:
> Is there a way to do:
> 
> NEW IS DISTINCT FROM OLD
> 
> in a trigger?
> 
> This would help me not have to write a specific trigger for each table.

One way would be to write the trigger function in a language other
than PL/pgSQL (PL/Tcl, PL/Perl, PL/Python, etc., depending on whether
the language in question supports triggers in the version of
PostgreSQL you're using).  Some languages' trigger functions receive
NEW and OLD in variables that can be inspected without knowing the
table structure in advance, so you can write generic functions that
will work on any table.

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/



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


end of thread, other threads:[~2005-08-04 13:38 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-08-03 17:52 NEW and OLD as ROWS Craig Servin <cservin@cromagnon.com>
2005-08-04 13:38 ` Michael Fuhr <mike@fuhr.org>

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