Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B9C39475FD4 for ; Tue, 27 Aug 2002 12:18:15 -0400 (EDT) Received: from aragorn.reaumur.absolight.net (ATuileries-113-2-1-126.abo.wanadoo.fr [80.11.216.126]) by postgresql.org (Postfix) with ESMTP id 18C80475FB4 for ; Tue, 27 Aug 2002 12:18:15 -0400 (EDT) Received: from andromede.reaumur.absolight.net (andromede.reaumur.absolight.net [212.43.217.61]) by aragorn.reaumur.absolight.net (Postfix) with ESMTP id B0C5083B6 for ; Tue, 27 Aug 2002 18:18:19 +0200 (CEST) Date: Tue, 27 Aug 2002 18:18:07 +0200 From: Mathieu Arnold To: pgsql-sql@postgresql.org Subject: triggers and plpgsql question Message-ID: <374862253.1030472287@andromede.reaumur.absolight.net> X-Mailer: Mulberry/3.0.0b1 (Win32) X-wazaaa: True, true MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/361 X-Sequence-Number: 9207 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