Reference to NEW, OLD values in TRIGGER

Started by Andrey Y. Mosienkoalmost 24 years ago1 messagesgeneral
Jump to latest

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;