Re: knowing which columns have beend UPDATEd inside a TRIGGER?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: ldm(at)apartia(dot)ch
Cc: pgsql-sql(at)hub(dot)org
Subject: Re: knowing which columns have beend UPDATEd inside a TRIGGER?
Date: 2000-10-24 22:51:03
Message-ID: 26414.972427863@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice pgsql-sql

Louis-David Mitterrand <cunctator(at)apartia(dot)ch> writes:
> Is there a way to know which columns are being UPDATEd or INSERTEd from
> inside a trigger, either in C or pl/pgsql?

Huh? An INSERT always inserts all columns, by definition. Some of them
might be null and/or equal to their default values, but they're all
there.

For an UPDATE, you could check to see whether old.col = new.col.
This would miss the case where an UPDATE command is explicitly setting
a column to the same value it already had; dunno if you care or not.

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message S.A.Pamungkas 2000-10-25 04:46:58 connect DB from remote
Previous Message Mark Volpe 2000-10-24 20:39:54 Re: [SQL] Re: NULL

Browse pgsql-sql by date

  From Date Subject
Next Message Brian C. Doyle 2000-10-24 23:00:48 Re: Alternate Database Locations
Previous Message Josh Berkus 2000-10-24 22:06:41 Re: Help on Union Query