Trigger to identify which column(s) updated - Mailing list pgsql-sql

From Jack Kerkhof
Subject Trigger to identify which column(s) updated
Date
Msg-id ENEIKKAEJOFHOIHMMOIDKEAFCJAA.jack.kerkhof@guest-tek.com
Whole thread Raw
Responses Re: Trigger to identify which column(s) updated
List pgsql-sql
Does anyone know how to write a trigger that would identify which columns
have actually changed in an update (and then log them to an archive).

I suspect that the function would look something like;

CREATE FUNCTION FIND_CHANGED_COLUMNS() RETURNS OPAQUE AS '
BEGIN
  -- FOR EACH COLUMN IN THE RECORD:     -- IF ( NEW COLUMNx <> OLD COLUMNx)        -- LOG THE RECORD PRIMARY KEY,
COLUMNNAME, OLD VALUE
 
  RETURN NEW;
END;
' LANGUAGE 'plpgsql';

In other words- How might you parse, in general, old and new records to compare like
columns?     - How can you find out the primary key of a record?

Thanks, Jack



pgsql-sql by date:

Previous
From: sad
Date:
Subject: DROP TRIGGER
Next
From: denis@coralindia.com
Date:
Subject: Initially Deffered - FK