X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id CD78CD1B49E for ; Thu, 4 Dec 2003 19:25:03 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 97456-05 for ; Thu, 4 Dec 2003 15:24:33 -0400 (AST) Received: from main.gmane.org (main.gmane.org [80.91.224.249]) by svr1.postgresql.org (Postfix) with ESMTP id CB9DBD1B483 for ; Thu, 4 Dec 2003 15:24:30 -0400 (AST) Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1ARz5S-0002qW-00 for ; Thu, 04 Dec 2003 20:24:30 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org Received: from sea.gmane.org ([80.91.224.252]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1ARz5R-0002qM-00 for ; Thu, 04 Dec 2003 20:24:29 +0100 Received: from news by sea.gmane.org with local (Exim 3.35 #1 (Debian)) id 1ARz5R-0008QK-00 for ; Thu, 04 Dec 2003 20:24:29 +0100 From: Jeff Kowalczyk Subject: Re: Trigger plpgsql function, how to test if OLD is set? Date: Thu, 04 Dec 2003 14:24:29 -0500 Lines: 14 Message-ID: References: <3FCF7ECA.5060200@klaster.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@sea.gmane.org User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/39 X-Sequence-Number: 16205 Tomasz Myrta wrote: > You can always check whether your trigger has been fired as insert or > update trigger. > DECLARE old_orderid integer; > BEGIN > if TG_OP=''UPDATE'' then > old_orderid=OLD.orderid; > else > old_orderid=-1; > end if; Thank you, that works well enough. I'm beginning to appreciate the complexity of working with both the familiar DRI (contraints) and triggers, which are something I have rarely used.