X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B29C5D1CA40 for ; Sun, 9 May 2004 23:48:15 -0300 (ADT) 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 00720-02 for ; Sun, 9 May 2004 23:47:57 -0300 (ADT) Received: from hotmail.com (bay1-f8.bay1.hotmail.com [65.54.245.8]) by svr1.postgresql.org (Postfix) with ESMTP id 6EBDBD1B4AE for ; Sun, 9 May 2004 23:47:53 -0300 (ADT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Sun, 9 May 2004 19:47:57 -0700 Received: from 210.0.221.178 by by1fd.bay1.hotmail.msn.com with HTTP; Mon, 10 May 2004 02:47:57 GMT X-Originating-IP: [210.0.221.178] X-Originating-Email: [cheungsw@hotmail.com] X-Sender: cheungsw@hotmail.com From: "Bernard Cheung" To: pgsql-sql@postgresql.org Subject: Trigger function to know which fields are being updated Date: Mon, 10 May 2004 10:47:57 +0800 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 10 May 2004 02:47:57.0752 (UTC) FILETIME=[33746B80:01C43639] X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=1.0 tagged_above=0.0 required=5.0 tests=FOR_FREE, LINES_OF_YELLING, UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200405/87 X-Sequence-Number: 17801 I am writing a trigger function. How can I know which fields are being updated in the PL/SQL function? For example I have a table here: CREATE TABLE COMPANY ( COMPANY_ID VARCHAR(10) NOT NULL, NAME VARCHAR(30), ADDRESS VARCHAR(30)); I want to write a trigger to block all update statements without updating NAME. I tried the following code block and it doesn't work: IF TG_OP = ''UPDATE'' THEN IF NEW.NAME IS NULL THEN RAISE NOTICE ''Field NAME must be provided!''; END IF; END IF; Are there any functions like the Oracle's UPDATING() predicate? Bernard Cheung _________________________________________________________________ Linguaphone : Learning English? Get Japanese lessons for FREE http://go.msnserver.com/HK/46165.asp