Re: wishlist for 8.4
| От | Heikki Linnakangas |
|---|---|
| Тема | Re: wishlist for 8.4 |
| Дата | |
| Msg-id | 47B595AD.5040602@enterprisedb.com обсуждение исходный текст |
| Ответ на | wishlist for 8.4 (Raphaël Jacquot <sxpert@sxpert.org>) |
| Список | 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;
RETURNNEW;
END;
$emp_stamp$ LANGUAGE plpgsql;
Not sure the quoting is right...
-- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com
В списке pgsql-hackers по дате отправления: