Trigger / Function: Getting column name of UPDATE

From: "Envex Developments" <mwagner(at)envex(dot)net>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Trigger / Function: Getting column name of UPDATE
Date: 2002-11-29 14:51:08
Message-ID: 012d01c297b6$c0cbf7f0$04f65618@mattbh97ynudvv
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Hey there,

I have a table named "program1", which looks like:

id INT NOT NULL
u1 INT
u2 INT
u3 INT
ds INT

I'm trying to keep a consitent summary of this table through the use of a
trigger, and function written in PL/pgSQL. The problem I'm having is when
the trigger is executed AFTER an UPDATE statement, there's no wayto
determine which uX column was updated. I need to know if it's u1, u2, or
u3.

I've been trying for loops such as:

-------------------
FOR x IN 1 .. 3 LOOP
IF OLD.ux NOT = NEW.ux THEN
.... do this ...
END IF;
END LOOP;
-------------------

Obviously, that doesn't work, and I just receive errors stating the column
ux doesn't exist. Was wondering if anyone out there knew how to get the
column name which was updated through a trigger? Anyway to pass it as an
argument to the function or anything?

Any help would be greatly appreciated.

Thanks,
Matt

Browse pgsql-general by date

  From Date Subject
Next Message Tomas Berndtsson 2002-11-29 15:13:05 message type 0x44 arrived from server while idle
Previous Message Shridhar Daithankar 2002-11-29 14:23:39 Re: FETCH a cursor inside a SELECT