triggers and plpgsql question

From: Mathieu Arnold <mat(at)mat(dot)cc>
To: pgsql-sql(at)postgresql(dot)org
Subject: triggers and plpgsql question
Date: 2002-08-27 16:18:07
Message-ID: 374862253.1030472287@andromede.reaumur.absolight.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi

I want to do a generic function that I can add to triggers to add every
inserts, updates and deletes from many differents tables into a common
format in another table. the idea is :

create function do_it_all () returns opaque '
begin
IF TG_OP = ''INSERT'' THEN
cycle through all of NEW (not knowing what it contains) and do things
with them
ELSIF TG_OP = ''UPDATE'' THEN
cycle through all of NEW (not knowing what it contains) and do things
with them
ELSIF TG_OP = ''DELETE'' THEN
say that NEW.id_||TG_RELNAME has been deleted
END IF;
END;

The thing I need, is to be able to know what does NEW contains, and I have
not found out any mean to do so. If it's not possible to do so, I'll write
a function per table, but for the beauty of all this, I would have liked to
do it the way above.

--
Mathieu Arnold

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Fritz Lehmann-Grube 2002-08-27 20:23:18 decode('hallo',???)
Previous Message Emmanuel Guyot 2002-08-27 09:52:46 Year of the week : How to ?