X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6D0DD52BCB for ; Thu, 4 Aug 2005 10:38:33 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41110-02 for ; Thu, 4 Aug 2005 13:38:31 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id EA48D52BBC for ; Thu, 4 Aug 2005 10:38:30 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j74DcPu8038095 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 4 Aug 2005 07:38:28 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j74DcPP6087901; Thu, 4 Aug 2005 07:38:25 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j74DcNpf087900; Thu, 4 Aug 2005 07:38:23 -0600 (MDT) (envelope-from mfuhr) Date: Thu, 4 Aug 2005 07:38:23 -0600 From: Michael Fuhr To: Craig Servin Cc: pgsql-sql@postgresql.org Subject: Re: NEW and OLD as ROWS Message-ID: <20050804133823.GA87839@winnie.fuhr.org> References: <200508031252.24844.cservin@cromagnon.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200508031252.24844.cservin@cromagnon.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200508/18 X-Sequence-Number: 22246 On Wed, Aug 03, 2005 at 12:52:24PM -0500, Craig Servin wrote: > Is there a way to do: > > NEW IS DISTINCT FROM OLD > > in a trigger? > > This would help me not have to write a specific trigger for each table. One way would be to write the trigger function in a language other than PL/pgSQL (PL/Tcl, PL/Perl, PL/Python, etc., depending on whether the language in question supports triggers in the version of PostgreSQL you're using). Some languages' trigger functions receive NEW and OLD in variables that can be inspected without knowing the table structure in advance, so you can write generic functions that will work on any table. -- Michael Fuhr http://www.fuhr.org/~mfuhr/