Reference to NEW, OLD values in TRIGGER

From: Andrey Mosienko <feo(at)ttn(dot)ru>
To: Postgres <pgsql-general(at)postgresql(dot)org>
Subject: Reference to NEW, OLD values in TRIGGER
Date: 2002-05-07 18:20:52
Message-ID: 3CD81B04.2020308@ttn.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello All!

How can I access NEW or OLD fields in trigger with variable?
I need it to create more universal function to work with tables
when I don't know the table structure.

Example:

Now:
IF NEW.empname ISNULL THEN
RAISE EXCEPTION ''empname cannot be NULL value'';
END IF;

As I wish. or something like that:
DECLARE
str text;
BEGIN
str := 'empname';
IF NEW.''str'' ISNULL THEN
^^^^^^
RAISE EXCEPTION ''empname cannot be NULL value'';
END IF;
END;

Browse pgsql-general by date

  From Date Subject
Next Message Jason Earl 2002-05-07 18:45:44 Re: Contrib reindex script:
Previous Message Neil Conway 2002-05-07 17:29:46 Re: Index usage vs large repetitions of key