referencing an unknown variable in the NEW record in a trigger - Mailing list pgsql-admin

From Conrad Vermeulen
Subject referencing an unknown variable in the NEW record in a trigger
Date
Msg-id FKEMIMFAIHJKGEBKMNNNEEHDCEAA.conrad@fastforward.za.net
Whole thread Raw
List pgsql-admin
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


pgsql-admin by date:

Previous
From: "Glenn Wiorek"
Date:
Subject: Re: language "plpgsql" does not exist
Next
From: Peter Eisentraut
Date:
Subject: Re: Prompts in psql