Thread: referencing an unknown variable in the NEW record in a trigger

referencing an unknown variable in the NEW record in a trigger

From
"Conrad Vermeulen"
Date:
Hi,

I have a situation where I need to dereference the fields in the NEW record
within a trigger.

I know the standard way where NEW.fieldname where fieldname is known before
hand. What if fieldname is a text variable?

Say,

--------------------------

DECLARE

    fldname text;

begin
    fldname = 'name';


    raise exception '% has value %', fldname, NEW.fldname; -- is this possible?

    return NEW;
end;

--------------------------

is there a way such as NEW.fldname, or NEW.%fldname, or NEW.$fldname?


Any help appreciated,

Thanks,

Conrad