pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Conrad Vermeulen <conrad@fastforward.za.net>
To: pgsql-admin@postgresql.org
Subject: referencing an unknown variable in the NEW record in a trigger
Date: Tue, 2 Sep 2003 18:08:59 +0200
Message-ID: <FKEMIMFAIHJKGEBKMNNNEEHDCEAA.conrad@fastforward.za.net> (raw)

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




Message-ID: <FKEMIMFAIHJKGEBKMNNNEEHDCEAA.conrad@fastforward.za.net>
Permalink:  ../FKEMIMFAIHJKGEBKMNNNEEHDCEAA.conrad@fastforward.za.net/
Also on:    postgresql.org/message-id/FKEMIMFAIHJKGEBKMNNNEEHDCEAA.conrad@fastforward.za.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: conrad@fastforward.za.net
  Subject: Re: referencing an unknown variable in the NEW record in a trigger
  In-Reply-To: <FKEMIMFAIHJKGEBKMNNNEEHDCEAA.conrad@fastforward.za.net>
  References: <FKEMIMFAIHJKGEBKMNNNEEHDCEAA.conrad@fastforward.za.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox