referencing an unknown variable in the NEW record in a trigger

From: "Conrad Vermeulen" <conrad(at)fastforward(dot)za(dot)net>
To: <pgsql-admin(at)postgresql(dot)org>
Subject: referencing an unknown variable in the NEW record in a trigger
Date: 2003-09-02 16:08:59
Message-ID: FKEMIMFAIHJKGEBKMNNNEEHDCEAA.conrad@fastforward.za.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-admin by date

  From Date Subject
Next Message Peter Eisentraut 2003-09-02 17:57:48 Re: Prompts in psql
Previous Message Villalba, Juan Jose - (Col) 2003-09-02 13:21:52 Version number question