Search Postgresql Archives

Trigger function to know which fields are being updated

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

_________________________________________________________________
No masks required! Use MSN Messenger to chat with friends and family. http://go.msnserver.com/HK/25382.asp



---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives?

http://archives.postgresql.org

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux