From: | "Heikki Linnakangas" <heikki(at)enterprisedb(dot)com> |
---|---|
To: | Raphaël Jacquot <sxpert(at)sxpert(dot)org> |
Cc: | <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: wishlist for 8.4 |
Date: | 2008-02-15 13:37:49 |
Message-ID: | 47B595AD.5040602@enterprisedb.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Raphaël Jacquot wrote:
> I recently found myself trying to build a trigger to modify some fields
> in a good dozen similarly structured tables in which the similar columns
> had different names.
> in fact, I got stuck in pl/pgsql with the fact that there's no way to
> access the NEW tuple in an indirect way, having the name of the column
> in some variable. (I found that it could be done in plperl, but that
> left me with a taste of un-completeness...)
It's ugly, but you could play tricks with EXECUTE. Like:
CREATE OR REPLACE FUNCTION emp_stamp() RETURNS trigger AS $emp_stamp$
DECLARE
empname text;
BEGIN
EXECUTE 'SELECT ('''||new||'''::emp).empname' INTO empname;
RAISE NOTICE 'new empname is: %', empname;
RETURN NEW;
END;
$emp_stamp$ LANGUAGE plpgsql;
Not sure the quoting is right...
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com
From | Date | Subject | |
---|---|---|---|
Next Message | Roberts, Jon | 2008-02-15 13:47:44 | Re: subquery in limit |
Previous Message | Sam Mason | 2008-02-15 13:05:16 | Re: wishlist for 8.4 |