pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bernard Cheung <cheungsw@hotmail.com>
To: pgsql-sql@postgresql.org
Subject: Trigger function to know which fields are being updated
Date: Mon, 10 May 2004 10:47:57 +0800
Message-ID: <BAY1-F8NsokLQ8aZRhQ0000aa28@hotmail.com> (raw)

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




view thread (5+ messages)  latest in thread

Message-ID: <BAY1-F8NsokLQ8aZRhQ0000aa28@hotmail.com>
Permalink:  ../BAY1-F8NsokLQ8aZRhQ0000aa28@hotmail.com/
Also on:    postgresql.org/message-id/BAY1-F8NsokLQ8aZRhQ0000aa28@hotmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: cheungsw@hotmail.com
  Subject: Re: Trigger function to know which fields are being updated
  In-Reply-To: <BAY1-F8NsokLQ8aZRhQ0000aa28@hotmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox