Trigger function to know which fields are being updated

From: "Bernard Cheung" <cheungsw(at)hotmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Trigger function to know which fields are being updated
Date: 2004-05-10 02:47:57
Message-ID: BAY1-F8NsokLQ8aZRhQ0000aa28@hotmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Bruce Momjian 2004-05-10 03:58:12 Re: Adding MERGE to the TODO list (resend with subject)
Previous Message Alvaro Herrera 2004-05-09 16:09:49 Re: Adding MERGE to the TODO list (resend with subject)